Consider adding method to execute update on PreparedStatement and check rows updated #1075
sleberknight
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The use case is when you have a JDBC
PreparedStatement
and you expect a specific number of rows to be updated, e.g. one for a SQLINSERT
. So, instead of:you could write:
It's trivial, but over time can save time and errors (e.g. by forgetting to check the number of rows updated).
We could also consider adding a similar method for
Statement
, but it has four overloadedexecuteUpdate
methods, so is it worth adding a method one, two, all, or none of them?Note that both
PreparedStatement
andStatement
also now (well, since Java 8) haveexecuteLargeUpdate
methods when the number of affected rows could possibly exceedInteger.MAX_VALUE
. This would add more methods, but I have never once issued a SQL query of any sort that affected more than 2,147,483,647 rows!Beta Was this translation helpful? Give feedback.
All reactions