coder616 opened a new issue, #20338:
URL: https://github.com/apache/shardingsphere/issues/20338
ShardingSphere version 5.1.2?
The database name cannot be properly obtained when using ShardingSphere-JDBC
to connect to a mysql instance proxied by ShardingSphere-proxy.
`private Map<String, Collection<ColumnMetaData>> loadColumnMetaDataMap(final
DataSource dataSource, final Collection<String> tables) throws SQLException {
Map<String, Collection<ColumnMetaData>> result = new HashMap<>();
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
connection.prepareStatement(getTableMetaDataSQL(tables))) {
Map<String, Integer> dataTypes =
DataTypeLoaderFactory.getInstance(DatabaseTypeFactory.getInstance("MySQL")).load(connection.getMetaData());
String databaseName = "".equals(connection.getCatalog()) ?
GlobalDataSourceRegistry.getInstance().getCachedDatabaseTables().get(tables.iterator().next())
: connection.getCatalog();
preparedStatement.setString(1, databaseName);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
String tableName = resultSet.getString("TABLE_NAME");
ColumnMetaData columnMetaData =
loadColumnMetaData(dataTypes, resultSet);
if (!result.containsKey(tableName)) {
result.put(tableName, new LinkedList<>());
}
result.get(tableName).add(columnMetaData);
}
}
}
return result;
}`
connection.getCatalog() returned is not real database name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]