|
@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
|
|
|
//version_4.0 whz 20240119修复修改和删除会更新整表的操作
|
|
//version_4.0 whz 20240119修复修改和删除会更新整表的操作
|
|
|
//version_4.1 whz 20240130修复修改不能改字段为空的问题
|
|
//version_4.1 whz 20240130修复修改不能改字段为空的问题
|
|
|
//version_4.2 whz 20240227修复in中不能使用非String类型的字段问题
|
|
//version_4.2 whz 20240227修复in中不能使用非String类型的字段问题
|
|
|
|
|
+@Slf4j
|
|
|
@Component
|
|
@Component
|
|
|
public class JdbcClient {
|
|
public class JdbcClient {
|
|
|
@Resource
|
|
@Resource
|
|
@@ -43,7 +44,7 @@ public class JdbcClient {
|
|
|
try {
|
|
try {
|
|
|
connection.close();
|
|
connection.close();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (statements.length > 0) {
|
|
if (statements.length > 0) {
|
|
@@ -51,7 +52,7 @@ public class JdbcClient {
|
|
|
try {
|
|
try {
|
|
|
statement.close();
|
|
statement.close();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -62,7 +63,7 @@ public class JdbcClient {
|
|
|
try {
|
|
try {
|
|
|
statement.close();
|
|
statement.close();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -73,7 +74,7 @@ public class JdbcClient {
|
|
|
connection.rollback();
|
|
connection.rollback();
|
|
|
}
|
|
}
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
|
- ex.printStackTrace();
|
|
|
|
|
|
|
+ log.error(ex.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -117,7 +118,6 @@ public class JdbcClient {
|
|
|
result.put("records", resultList);
|
|
result.put("records", resultList);
|
|
|
return result;
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -168,7 +168,6 @@ public class JdbcClient {
|
|
|
result.put("records", resultList);
|
|
result.put("records", resultList);
|
|
|
return result;
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -221,7 +220,6 @@ public class JdbcClient {
|
|
|
result.put("records", resultList);
|
|
result.put("records", resultList);
|
|
|
return result;
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -259,7 +257,6 @@ public class JdbcClient {
|
|
|
List<Map<String, Object>> resultList = ResultSetUtil.formatResultSetToListMap(resultSet);
|
|
List<Map<String, Object>> resultList = ResultSetUtil.formatResultSetToListMap(resultSet);
|
|
|
return resultList;
|
|
return resultList;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -298,7 +295,6 @@ public class JdbcClient {
|
|
|
List<T> resultList = ResultSetUtil.formatResultSetToList(resultSet, clazz);
|
|
List<T> resultList = ResultSetUtil.formatResultSetToList(resultSet, clazz);
|
|
|
return resultList;
|
|
return resultList;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -329,7 +325,6 @@ public class JdbcClient {
|
|
|
List<T> resultList = (List<T>) ResultSetUtil.formatResultSetToList(resultSet, object.getClass());
|
|
List<T> resultList = (List<T>) ResultSetUtil.formatResultSetToList(resultSet, object.getClass());
|
|
|
return resultList;
|
|
return resultList;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -369,7 +364,6 @@ public class JdbcClient {
|
|
|
List<T> resultList = ResultSetUtil.formatResultSetToList(resultSet, clazz);
|
|
List<T> resultList = ResultSetUtil.formatResultSetToList(resultSet, clazz);
|
|
|
return resultList;
|
|
return resultList;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -408,7 +402,6 @@ public class JdbcClient {
|
|
|
|
|
|
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, obj.getClass());
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, obj.getClass());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -436,7 +429,6 @@ public class JdbcClient {
|
|
|
|
|
|
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, clazz);
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, clazz);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -463,7 +455,6 @@ public class JdbcClient {
|
|
|
|
|
|
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, clazz);
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, clazz);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -502,7 +493,6 @@ public class JdbcClient {
|
|
|
|
|
|
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, obj.getClass());
|
|
return (T) ResultSetUtil.formatResultSetToModel(resultSet, obj.getClass());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -540,7 +530,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -566,7 +555,6 @@ public class JdbcClient {
|
|
|
sql = ResultSetUtil.formatInsertSql(model);
|
|
sql = ResultSetUtil.formatInsertSql(model);
|
|
|
statement.executeUpdate(sql);
|
|
statement.executeUpdate(sql);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -605,7 +593,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -663,7 +650,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -703,7 +689,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -729,7 +714,6 @@ public class JdbcClient {
|
|
|
sql = ResultSetUtil.formatRemoveByIdSql(model);
|
|
sql = ResultSetUtil.formatRemoveByIdSql(model);
|
|
|
statement.executeUpdate(sql);
|
|
statement.executeUpdate(sql);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -761,7 +745,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -798,7 +781,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|
|
@@ -828,7 +810,6 @@ public class JdbcClient {
|
|
|
}
|
|
}
|
|
|
return 0;
|
|
return 0;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
throw e;
|
|
throw e;
|
|
|
} finally {
|
|
} finally {
|
|
|
if (connections.length == 0) {
|
|
if (connections.length == 0) {
|