Reputation:
I am trying to Update my data from my netbeans to sqlite. there is no problem with the query but when I run the program a message box will appear "java.sql.SQLException:query does not return results". What seems to be the problem?
try{
String value1=txtId.getText();
String value2=txtFirst.getText();
String value3=txtLast.getText();
String value4=txtUser.getText();
String value5=txtPass.getText();
String sql="Update account set id='"+value1+"', fname='"+value2+"', lname='"+value3+"',username='"+value4+"', password='"+value5+"' where id='"+value1+"' ";
pst=conn.prepareStatement(sql);
rs=pst.executeQuery();
JOptionPane.showMessageDialog(null,"Data Updated");
}
catch(SQLException e){
JOptionPane.showMessageDialog(null,e);
}
Upvotes: 0
Views: 11719
Reputation: 1
You can also try:
String strQuery = ("update visitor set name='"+jTextField10.getText()+"',bus_no='"+jTextField9.getText()+"',cus_name='"+jTextField8.getText()+"',Date='"+jTextField7.getText()+"',amount='"+jTextField6.getText()+"' where _ID='"+jTextField8.getText()+"' ");
Upvotes: 0
Reputation: 1
Update query:
st.executeUpdate("update reservation set busname='"+jTextField10.getText()+"',busno='"+jTextField9.getText()+"',cusname='"+jTextField8.getText()+"',noofpass='"+jTextField7.getText()+"',amount='"+jTextField6.getText()+"' where cusname='"+jTextField8.getText()+"' ");
Upvotes: 0
Reputation: 109557
int updateCount = pst.executeUpdate();
Instead of executeQuery.
Upvotes: 2