|
@@ -52,16 +52,17 @@ public class BatchExecutor implements Closeable {
|
|
|
}
|
|
|
|
|
|
public void execute(String sql, List<Map<String, ?>> values) throws SQLException {
|
|
|
- PreparedStatement pstmt = getConn().prepareStatement(sql);
|
|
|
- int len = values.size();
|
|
|
- for (int i = 0; i < len; i++) {
|
|
|
- int type = (Integer) values.get(i).get("type");
|
|
|
- Object value = values.get(i).get("value");
|
|
|
- SyncUtil.setPStmt(type, pstmt, value, i + 1);
|
|
|
- }
|
|
|
+ try (PreparedStatement pstmt = getConn().prepareStatement(sql)) {
|
|
|
+ int len = values.size();
|
|
|
+ for (int i = 0; i < len; i++) {
|
|
|
+ int type = (Integer) values.get(i).get("type");
|
|
|
+ Object value = values.get(i).get("value");
|
|
|
+ SyncUtil.setPStmt(type, pstmt, value, i + 1);
|
|
|
+ }
|
|
|
|
|
|
- pstmt.execute();
|
|
|
- idx.incrementAndGet();
|
|
|
+ pstmt.execute();
|
|
|
+ idx.incrementAndGet();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void commit() throws SQLException {
|