Reputation: 71
This is the relevant bit of code,
createconn = new CreateConnection();
con = createconn.connect_to_database();
String SQL = "UPDATE User SET Password = SHA2(?,512) WHERE Login = ? AND Password = SHA2(?,512)";
stmt = con.prepareStatement(SQL);
stmt.setString(1, NewPassword);
stmt.setString(2, Login);
stmt.setString(3, CurrentPassword);
int count = stmt.executeUpdate();
System.out.println("Rows affected: " + count);
count always is set to 0, i.e., no rows are updated, even when current password is correct. What's worse, no exception is generated. (even when current password is wrong)
When I use a fixed statement (using fixed values for the three parameters), the code works, just not when written like this.
This whole code is inside a function which takes the three parameters as arguments.
Any help is appreciated.
Upvotes: 0
Views: 110
Reputation: 109547
PASSWORD is a reserved word, maybe the workbench is a bit more lenient/intelligent. Try adding back ticks around.
`Password`
Upvotes: 1