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 54626c09..5f9d9b00 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 @@ -536,7 +536,7 @@ public class DbReadTableUtil { } //通过表名获取表备注 - public String remarks(String a) throws SQLException, ClassNotFoundException { + public String remarks(String tableName) throws SQLException, ClassNotFoundException { Connection connection = null; Statement statement = null; try { @@ -544,7 +544,15 @@ public class DbReadTableUtil { connection = DriverManager.getConnection(com.jero.codegenerate.properties.CodeConfigProperties.databaseUrl, com.jero.codegenerate.properties.CodeConfigProperties.username, com.jero.codegenerate.properties.CodeConfigProperties.password); statement = connection.createStatement(1005, 1007); - String sqlStr = "SELECT table_comment FROM information_schema.TABLES WHERE table_name = " + "'"+a+"'"; + String sqlStr = ""; + if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.MYSQL)) { + // mysql获取表的列信息sql + sqlStr = "SELECT table_comment FROM information_schema.TABLES WHERE table_name = " + "'"+tableName+"'"; + } + // oracle获取表的列信息sql + if (com.jero.codegenerate.properties.CodeConfigProperties.databaseType.equals(DbConvertDef.ORACLE)) { + sqlStr = "SELECT comments FROM user_tab_comments WHERE table_name = '" + tableName.toUpperCase() + "'"; + } ResultSet resultSet = statement.executeQuery(sqlStr); while(resultSet.next()) { String name = resultSet.getString(1);