Skip to content

Commit

Permalink
[apache#1701] fix(mysql): Compatible with lower versions of MySQL dri…
Browse files Browse the repository at this point in the history
…ver, unable to obtain table comments.
  • Loading branch information
Clearvive authored and Clearvive committed Jan 25, 2024
1 parent ee9ee24 commit 8d6852c
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public JdbcTable load(String databaseName, String tableName) throws NoSuchTableE
String comment = table.getString("REMARKS");
if (StringUtils.isEmpty(comment)) {
// In Mysql version 5.7, the comment field value cannot be obtained in the driver API.
LOG.warn(
"Not found comment in mysql driver api. Will try to get comment from the system table");
comment = loadCommentFromSysTable(connection, tableName);
LOG.warn("Not found comment in mysql driver api. Will try to get comment from sql");
comment = loadCommentFromSql(connection, tableName);
}

// 2.Get column information
Expand Down Expand Up @@ -91,8 +90,7 @@ public JdbcTable load(String databaseName, String tableName) throws NoSuchTableE
}
}

private String loadCommentFromSysTable(Connection connection, String tableName)
throws SQLException {
private String loadCommentFromSql(Connection connection, String tableName) throws SQLException {
try (PreparedStatement statement = connection.prepareStatement("SHOW TABLE STATUS LIKE ?")) {
statement.setString(1, tableName);
try (ResultSet resultSet = statement.executeQuery()) {
Expand Down

0 comments on commit 8d6852c

Please sign in to comment.