From 46f0f8b784b4b27af0d92c9f38d44bdd12df8846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Mon, 3 Apr 2023 11:04:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=20sonar=E3=80=91DbReadTableUtil?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jero/codegenerate/database/DbReadTableUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java b/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java index 5d5a8bc4..54626c09 100644 --- a/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java +++ b/jero-boot/jero-boot-base/jero-boot-base-generater-core/src/main/java/com/jero/codegenerate/database/DbReadTableUtil.java @@ -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 */ - public static List listColumns(String tableName) throws Exception{ + public static List listColumns(String tableName) throws SQLException, ClassNotFoundException { String sqlStr = null; ArrayList 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 */ - public static List listOriginalColumns(String tableName) throws Exception { + public static List listOriginalColumns(String tableName) throws SQLException, ClassNotFoundException { ResultSet resultSet; String sqlStr = null; ArrayList 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();