diff --git a/CHANGELOG.md b/CHANGELOG.md index 1273f46f2..e4ab637d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ * 【crypto 】 增加CipherWrapper,增加setRandom(issue#1958@Github) * 【core 】 Opt增加ofTry方法(pr#1956@Github) * 【core 】 DateUtil.toIntSecond标记为弃用(issue#I4JHPR@Gitee) +* 【db 】 Db.executeBatch标记一个重载为弃用(issue#I4JIPH@Gitee) * ### 🐞Bug修复 * 【core 】 修复FileResource构造fileName参数无效问题(issue#1942@Github) diff --git a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java b/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java index 77c20fcc4..0c40d4de2 100644 --- a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java +++ b/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java @@ -239,7 +239,9 @@ public abstract class AbstractDb implements Serializable { * @param paramsBatch 批量的参数 * @return 每个SQL执行影响的行数 * @throws SQLException SQL执行异常 + * @deprecated 编译器无法区分重载 */ + @Deprecated public int[] executeBatch(String sql, Object[]... paramsBatch) throws SQLException { Connection conn = null; try { diff --git a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java b/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java index a64973625..e3aa4439b 100644 --- a/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java +++ b/hutool-db/src/main/java/cn/hutool/db/sql/SqlExecutor.java @@ -16,7 +16,7 @@ import java.util.Map; /** * SQL执行器,全部为静态方法,执行查询或非查询的SQL语句
* 此方法为JDBC的简单封装,与数据库类型无关 - * + * * @author loolly * */ @@ -26,7 +26,7 @@ public class SqlExecutor { * 执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL,使用name做为占位符,例如:name * @param paramMap 参数Map @@ -43,7 +43,7 @@ public class SqlExecutor { * 执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param params 参数 @@ -63,7 +63,7 @@ public class SqlExecutor { /** * 执行调用存储过程
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param params 参数 @@ -83,7 +83,7 @@ public class SqlExecutor { /** * 执行调用存储过程
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param params 参数 @@ -99,7 +99,7 @@ public class SqlExecutor { * 执行非查询语句,返回主键
* 发查询语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param paramMap 参数Map @@ -116,7 +116,7 @@ public class SqlExecutor { * 执行非查询语句,返回主键
* 发查询语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param params 参数 @@ -148,22 +148,24 @@ public class SqlExecutor { * 批量执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param paramsBatch 批量的参数 * @return 每个SQL执行影响的行数 * @throws SQLException SQL执行异常 + * @deprecated 重载导致编译器无法区分 */ + @Deprecated public static int[] executeBatch(Connection conn, String sql, Object[]... paramsBatch) throws SQLException { return executeBatch(conn, sql, new ArrayIter<>(paramsBatch)); } - + /** * 批量执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sql SQL * @param paramsBatch 批量的参数 @@ -179,12 +181,12 @@ public class SqlExecutor { DbUtil.close(ps); } } - + /** * 批量执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sqls SQL列表 * @return 每个SQL执行影响的行数 @@ -194,12 +196,12 @@ public class SqlExecutor { public static int[] executeBatch(Connection conn, String... sqls) throws SQLException { return executeBatch(conn, new ArrayIter<>(sqls)); } - + /** * 批量执行非查询语句
* 语句包括 插入、更新、删除
* 此方法不会关闭Connection - * + * * @param conn 数据库连接对象 * @param sqls SQL列表 * @return 每个SQL执行影响的行数 @@ -222,7 +224,7 @@ public class SqlExecutor { /** * 执行查询语句,例如:select * from table where field1=:name1
* 此方法不会关闭Connection - * + * * @param 处理结果类型 * @param conn 数据库连接对象 * @param sql 查询语句,使用参数名占位符,例如:name @@ -240,7 +242,7 @@ public class SqlExecutor { /** * 执行查询语句
* 此方法不会关闭Connection - * + * * @param 处理结果类型 * @param conn 数据库连接对象 * @param sql 查询语句 @@ -282,7 +284,7 @@ public class SqlExecutor { * executeUpdate 的返回值是一个整数(int),指示受影响的行数(即更新计数)。
* 对于 CREATE TABLE 或 DROP TABLE 等不操作行的语句,executeUpdate 的返回值总为零。
* 此方法不会关闭PreparedStatement - * + * * @param ps PreparedStatement对象 * @param params 参数 * @return 影响的行数 @@ -297,7 +299,7 @@ public class SqlExecutor { * 可用于执行任何SQL语句,返回一个boolean值,表明执行该SQL语句是否返回了ResultSet。
* 如果执行后第一个结果是ResultSet,则返回true,否则返回false。
* 此方法不会关闭PreparedStatement - * + * * @param ps PreparedStatement对象 * @param params 参数 * @return 如果执行后第一个结果是ResultSet,则返回true,否则返回false。 @@ -311,7 +313,7 @@ public class SqlExecutor { /** * 执行查询语句
* 此方法不会关闭PreparedStatement - * + * * @param 处理结果类型 * @param ps PreparedStatement * @param rsh 结果集处理对象 @@ -326,7 +328,7 @@ public class SqlExecutor { /** * 执行查询语句并关闭PreparedStatement - * + * * @param 处理结果类型 * @param ps PreparedStatement * @param rsh 结果集处理对象 @@ -345,7 +347,7 @@ public class SqlExecutor { // -------------------------------------------------------------------------------------------------------------------------------- Private method start /** * 执行查询 - * + * * @param ps {@link PreparedStatement} * @param rsh 结果集处理对象 * @return 结果对象