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



##########
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:
       In addition, you can use the `checkStyle` plugin to check the code 
format, this is the result of my checking this file.
   
   
![image](https://user-images.githubusercontent.com/52209337/137307961-f94af765-5aab-409e-b59e-b8f18b5dd84f.png)
   
   
![image](https://user-images.githubusercontent.com/52209337/137308385-b8933abe-e7b3-4df8-9d1e-8dc10252a84f.png)
   




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