add methods

This commit is contained in:
Looly
2020-09-02 23:14:02 +08:00
parent 39021446ad
commit e62a91ca38
2 changed files with 38 additions and 0 deletions

View File

@@ -248,6 +248,25 @@ public abstract class AbstractDb implements Serializable {
}
}
/**
* 批量执行非查询语句
*
* @param sql SQL
* @param paramsBatch 批量的参数
* @return 每个SQL执行影响的行数
* @throws SQLException SQL执行异常
* @since 5.4.2
*/
public int[] executeBatch(String sql, Iterable<Object[]> paramsBatch) throws SQLException {
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.executeBatch(conn, sql, paramsBatch);
} finally {
this.closeConnection(conn);
}
}
/**
* 批量执行非查询语句
*
@@ -266,6 +285,24 @@ public abstract class AbstractDb implements Serializable {
}
}
/**
* 批量执行非查询语句
*
* @param sqls SQL列表
* @return 每个SQL执行影响的行数
* @throws SQLException SQL执行异常
* @since 5.4.2
*/
public int[] executeBatch(Iterable<String> sqls) throws SQLException {
Connection conn = null;
try {
conn = this.getConnection();
return SqlExecutor.executeBatch(conn, sqls);
} finally {
this.closeConnection(conn);
}
}
// ---------------------------------------------------------------------------- CRUD start
/**