Java Database Connectivity (JDBC) examples. SQL with Java.
It is important to keep in mind, that each update added to a Statement or PreparedStatement is executed separately by the database. That means, that some of them may succeed before one of them fails. All the statements that have succeeded are now applied to the database, but the rest of the updates may not be. This can result in an inconsistent data in the database.
To avoid this, you can execute the batch update inside a transaction. When executed inside a transaction you can make