【fix sonar】DbReadTableUtil文件
This commit is contained in:
+5
-4
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -108,7 +109,7 @@ public class DbReadTableUtil {
|
|||||||
* @param tableName
|
* @param tableName
|
||||||
* @return java.util.List<com.jero.codegenerate.generate.pojo.ColumnVo>
|
* @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;
|
String sqlStr = null;
|
||||||
ArrayList<ColumnVo> list = new ArrayList<>();
|
ArrayList<ColumnVo> list = new ArrayList<>();
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
@@ -130,7 +131,7 @@ public class DbReadTableUtil {
|
|||||||
// 返回结果是当前数据集的行号,而不是结果的行数
|
// 返回结果是当前数据集的行号,而不是结果的行数
|
||||||
row = resultSet.getRow();
|
row = resultSet.getRow();
|
||||||
if (row <= 0) {
|
if (row <= 0) {
|
||||||
throw new Exception("该表不存在或者表中没有字段");
|
throw new IllegalArgumentException("该表不存在或者表中没有字段");
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnVo columnVo = new ColumnVo();
|
ColumnVo columnVo = new ColumnVo();
|
||||||
@@ -215,7 +216,7 @@ public class DbReadTableUtil {
|
|||||||
* @param tableName
|
* @param tableName
|
||||||
* @return java.util.List<com.jero.codegenerate.generate.pojo.ColumnVo>
|
* @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;
|
ResultSet resultSet;
|
||||||
String sqlStr = null;
|
String sqlStr = null;
|
||||||
ArrayList<ColumnVo> list = new ArrayList<>();
|
ArrayList<ColumnVo> list = new ArrayList<>();
|
||||||
@@ -237,7 +238,7 @@ public class DbReadTableUtil {
|
|||||||
// 返回结果是当前数据集的行号,而不是结果的行数
|
// 返回结果是当前数据集的行号,而不是结果的行数
|
||||||
row = resultSet.getRow();
|
row = resultSet.getRow();
|
||||||
if (row <= 0) {
|
if (row <= 0) {
|
||||||
throw new Exception("该表不存在或者表中没有字段");
|
throw new IllegalArgumentException("该表不存在或者表中没有字段");
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnVo columnVo = new ColumnVo();
|
ColumnVo columnVo = new ColumnVo();
|
||||||
|
|||||||
Reference in New Issue
Block a user