I am having a problem with an MySQL Update query. Here is the code:
String s2="foo";
String s6="bar";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","root");
String query="update mydb set Status='"+s6+"' where IC_Number='"+s2+"'";
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
con.close();
}
catch(Exception e)
{
System.out.println("Error in login:"+e);
}
}
}
I get the error
can not issue data manipulation statements with executeQuery().
Can anyone point out where the problem is ?
For
update
operation you have to useexecuteUpdate
which returns an integer but not aResultSet
Change:
To:
Documentation: