lanchengx commented on a change in pull request #13034:
URL: https://github.com/apache/shardingsphere/pull/13034#discussion_r728747101



##########
File path: 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/AbstractSelectInformationExecutor.java
##########
@@ -153,7 +153,14 @@ protected Object getSourceData(final String schemaName) 
throws SQLException {
             ShardingSphereResource resource = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(schemaName).getResource();
             Optional<Entry<String, DataSource>> dataSourceEntry = 
resource.getDataSources().entrySet().stream().findFirst();
             log.info("Actual SQL: {} ::: {}", 
dataSourceEntry.orElseThrow(DatabaseNotExistedException::new).getKey(), sql);
-            return 
dataSourceEntry.get().getValue().getConnection().prepareStatement(sql).executeQuery();
+            Connection conn = dataSourceEntry.get().getValue().getConnection();
+            try {
+                return conn.prepareStatement(sql).executeQuery();
+            } catch (SQLException e) {
+                throw e;
+            } finally {
+                conn.close();
+            }

Review comment:
       It is correct, but after closing, we can't get the query result in 
`ResultSet`, so we need to copy the data in `ResultSet` as the return result.




-- 
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]


Reply via email to