Created
December 13, 2017 02:15
-
-
Save nbkhope/bc3ddd0ca77f57304cbe6708ee37abbb to your computer and use it in GitHub Desktop.
Efficient JDBC Multiple Queries using PreparedStatement Batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
connection.setAutoCommit(false); | |
PreparedStatement preparedStatement = connection.prepareStatement(someQuery); | |
for (Record record : records) { | |
// do your stuff (e.g. preparedStatement.setString(1, name); | |
preparedStatement.addBatch(); | |
} | |
preparedStatement.executeBatch(); | |
connection.commit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment