Commit 6694fbfd by flying-cattle

解决代码质检问题

parent c4fd107c
...@@ -34,12 +34,13 @@ public class EntityInfoUtil { ...@@ -34,12 +34,13 @@ public class EntityInfoUtil {
// 创建连接 // 创建连接
Connection con = null; Connection con = null;
PreparedStatement pstemt = null; PreparedStatement pstemt = null;
ResultSet rs = null;
//sql //sql
String sql="select column_name,data_type,column_comment from information_schema.columns where table_schema='"+bi.getDatabase()+"' and table_name='"+bi.getTable()+"'"; String sql="select column_name,data_type,column_comment from information_schema.columns where table_schema='"+bi.getDatabase()+"' and table_name='"+bi.getTable()+"'";
try { try {
con = DriverManager.getConnection(bi.getDbUrl(), bi.getDbName(), bi.getDbPassword()); con = DriverManager.getConnection(bi.getDbUrl(), bi.getDbName(), bi.getDbPassword());
pstemt = con.prepareStatement(sql); pstemt = con.prepareStatement(sql);
ResultSet rs = pstemt.executeQuery(); rs = pstemt.executeQuery();
while (rs.next()) { while (rs.next()) {
String column = rs.getString(1); String column = rs.getString(1);
String jdbcType = rs.getString(2); String jdbcType = rs.getString(2);
...@@ -73,6 +74,10 @@ public class EntityInfoUtil { ...@@ -73,6 +74,10 @@ public class EntityInfoUtil {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("自动生成实体类错误:"+e.getMessage()); throw new RuntimeException("自动生成实体类错误:"+e.getMessage());
} finally { } finally {
try{
if(rs!=null) rs.close();
}catch(SQLException se2){
}
// 关闭资源 // 关闭资源
try{ try{
if(pstemt!=null) pstemt.close(); if(pstemt!=null) pstemt.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment