I need to show the result in Row of JTable
by calculate the value of rows using MySQL. Recevied + PCU stored in Balance when the user click the save button. What will be the query?
JTable
showing the records; save the record of the table.
JButton btnSave = new JButton("Save");
Image img4= new ImageIcon(this.getClass().getResource("/save.png")).getImage();
btnSave.setIcon(new ImageIcon(img4));
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String query="insert into Detail (ID,Date,Received,PCU,CLR,Sole,Sale,Balance) values (?,?,?,?,?,?,?,?)";
PreparedStatement pst=connection.prepareStatement(query);
pst.setString(1,textField.getText());
pst.setString(2,textField_1.getText());
pst.setString(3,textField_2.getText());
pst.setString(4,textField_3.getText());
pst.setString(5,textField_4.getText());
pst.setString(6,textField_5.getText());
pst.setString(7,textField_6.getText());
pst.setInt(8, 2-3 );
pst.execute();
JOptionPane.showMessageDialog(null, "Data Saved");
pst.close();
//rs.close();
}catch(Exception e){
e.printStackTrace();
}
refreshTable();
}