Let's see the execution result when using prepared statements in JDBC

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.

References

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

Let's see the execution result when using prepared statements in JDBC
Let's specify the version when using docker
Return the execution result of Service class in ServiceResponse class
Things to keep in mind when using if statements
Differences in code when using the length system in Java
Template creation program when using the reminder function in slack
When using JDBC, NLS parameters are affected by the Java locale.
How to solve the unknown error when using slf4j in Java
Precautions when using checkboxes in Thymeleaf
I summarized the points to note when using resources and resources in combination