Hello,
I'm creating a web application which displays record stored in an mysql database. I have created a PreparedStatement method as follows:
public static void doPreparedStatements(Connection conn, ResultSet rsClients, int rowInt){
String sql = "UPDATE clients SET firstName = ? WHERE clientID=" +rowInt;
PreparedStatement ps = null;
System.out.println("sql = " +sql);
try {
// Updating the database.
ps = conn.prepareStatement(sql);
ps.setString(1, rsClients.getString("firstName"));
ps.executeUpdate();
} catch (SQLException sqle) {
System.err.println("Error! Opening connection has failed: " + sqle);
sqle.printStackTrace();
}
}
I'm very new to
jdbc and sql and I cannot see what is wrong with the sql statement above - it does not error and it does not update the mysql database.
Can anyone see anything wrong with sql.
Any help will be greatly appreciated.
Cheers Joe.