Reputation: 7121
I am trying to update my table 'total':
in the row of id = 1, I want to update the value of 'days_left' to be 47.
String values_to_update = "UPDATE total SET days_left = '47' where id = '1'";
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(url, "root", "Admin");
PreparedStatement ps = con.prepareStatement(values_to_update);
con.close();
Why isn't it updated?
Upvotes: 0
Views: 89
Reputation: 9711
Do ...
ps.executeUpdate()
... before you close the connection. It doesn't look like you need a prepared statement either. A statement will do in your case.
Upvotes: 1
Reputation: 3633
At least, you need to execute your SQL statement via : ps.executeUpdate();
Upvotes: 1
Reputation: 34657
You need to execute the prepared statement. Try:
ps.executeUpdate();
con.commit();
before you close the connection.
Upvotes: 1