I want to know how I can update specific cells in jTable (in Java) using SQL.
This my try but it doesn’t work.
public void actionPerformed(ActionEvent e) {
int sel_tab=jTable1.getSelectedRow();
myDbConnection dbconnect;
dbconnect = new myDbConnection();
ResultSet resultSet =null;
resultSet = dbconnect.excuteQuery("SELECT id, area,location, status1 FROM pledges ");
if(e.getSource()==jButton1){
try {
String n = resultSet.getString("id");
String a = resultSet.getString("area");
String p = resultSet.getString("location");
String se = resultSet.getString("status1");
dbconnect.excuteUpdate("update pledges SET area="+ a +" whare id= "+sel_tab+"");
} catch (SQLException ex) {;}
}
}
Note: I am working in Netbeans.
finally I’ve found the correct answer
the following code will explain every thing
thanks for every one helped me