This commit is contained in:
mcy
2019-02-22 17:09:50 +08:00
parent 17efc2ada0
commit fcc1fc78ae

View File

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