On Jtable Update.
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
System.out.println("NAVEEN");
int row=jTable2.getSelectedRow();
System.out.println(""+row);
String t1=(jTable2.getModel().getValueAt(row, 0).toString());
System.out.println(""+t1);
String name = (jTable2.getModel().getValueAt(row, 1).toString());
System.out.println(name);
String mail = (jTable2.getModel().getValueAt(row, 2).toString());
String add = (jTable2.getModel().getValueAt(row, 3).toString());
System.out.println(add);
String pass = (jTable2.getModel().getValueAt(row, 4).toString());
System.out.println(pass);
try{
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/naveen","root","root");
String query = "update jtable set name=?,mail=?,address=?,password=? where id='"+t1+"'" ;
PreparedStatement stmt = con.prepareStatement(query);
stmt.setString(1, name); //Invoice No
stmt.setString(2, mail); //Code
stmt.setString(3, add); //Description
stmt.setString(4,pass); //Bonusable
stmt.executeUpdate();
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(null, "Cannot save. "+ ex);
}
set();
}