Execute SQL statements with prepared statements when using Java JDBC
String sql = "sql statement";
stmt = conn.prepareStatement(sql);
stmt.setQueryTimeout(10);
stmt.setString(1, table);
stmt.setString(2, username);
int count = stmt.executeUpdate();//Run with this
stmt.close();
return (count > 0); // affected row(If you were affected by more than one column, you were successful, right? Interpreted as.)
I couldn't think of judging from the number of affected rows.
https://stackoverflow.com/questions/24378270/how-do-you-determine-if-an-insert-or-update-was-successful-using-java-and-mysql https://code.i-harness.com/ja/q/d4d07c
Recommended Posts