To get help you can see the video.
Source code for signup page.
- Insert code
First you need to insert value into the table then you show value in table.
try {
if (jTextField_User.getText().equals("") || jTextField_lastName.getText().equals("") ||
jTextField_Email.getText().equals("") || jTextField_Age.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Fieldes Must Not be Empty...");
} else {
String query = "insert into user(f_name,l_name,email,gender,age,confermation) values(?,?,?,?,?,?)";
pst = con.prepareStatement(query);
pst.setString(1, jTextField_User.getText());
pst.setString(2, jTextField_lastName.getText());
pst.setString(3, jTextField_Email.getText());
pst.setString(4, (String) jComboBox1.getSelectedItem());
pst.setString(5, jTextField_Age.getText());
pst.setString(6, conferm);
pst.execute();
JOptionPane.showMessageDialog(null, "Created Successfully..");
showValueInTable();
}
} catch (HeadlessException | SQLException e) {
JOptionPane.showMessageDialog(null, "Not Created...");
}
2. show value in table.
public void showValueInTable(){
try{
String sql = "select * from user";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e);
}
}
Be First to Comment