1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
con.setAutoCommit(false); // If some fail, we want to rollback the rest
PreparedStatement stmt = con.prepareStatement(
"INSERT INTO CUSTOMERS VALUES (?,?,?)");
stmt.setFetchSize(500); /* Fais quelques essais pour trouver la valeur optimale */
stmt.setInt(1,1);
stmt.setString(2, "J Smith");
stmt.setString(3, "617 555-1323");
stmt.addBatch();
stmt.setInt(1,2);
stmt.setString(2, "A Smith");
stmt.setString(3, "617 555-1132");
stmt.addBatch();
int[] upCounts = stmt.executeBatch();
con.commit(); |
Partager