【fix sonar】DbReadTableUtil文件

This commit is contained in:
梁琦涛
2023-04-03 11:04:39 +08:00
parent f750075a5f
commit 46f0f8b784
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import java.sql.*;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -108,7 +109,7 @@ public class DbReadTableUtil {
* @param tableName
* @return java.util.List<com.jero.codegenerate.generate.pojo.ColumnVo>
*/
public static List<ColumnVo> listColumns(String tableName) throws Exception{
public static List<ColumnVo> listColumns(String tableName) throws SQLException, ClassNotFoundException {
String sqlStr = null;
ArrayList<ColumnVo> list = new ArrayList<>();
Connection connection = null;
@@ -130,7 +131,7 @@ public class DbReadTableUtil {
// 返回结果是当前数据集的行号,而不是结果的行数
row = resultSet.getRow();
if (row <= 0) {
throw new Exception("该表不存在或者表中没有字段");
throw new IllegalArgumentException("该表不存在或者表中没有字段");
}
ColumnVo columnVo = new ColumnVo();
@@ -215,7 +216,7 @@ public class DbReadTableUtil {
* @param tableName
* @return java.util.List<com.jero.codegenerate.generate.pojo.ColumnVo>
*/
public static List<ColumnVo> listOriginalColumns(String tableName) throws Exception {
public static List<ColumnVo> listOriginalColumns(String tableName) throws SQLException, ClassNotFoundException {
ResultSet resultSet;
String sqlStr = null;
ArrayList<ColumnVo> list = new ArrayList<>();
@@ -237,7 +238,7 @@ public class DbReadTableUtil {
// 返回结果是当前数据集的行号,而不是结果的行数
row = resultSet.getRow();
if (row <= 0) {
throw new Exception("该表不存在或者表中没有字段");
throw new IllegalArgumentException("该表不存在或者表中没有字段");
}
ColumnVo columnVo = new ColumnVo();