You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/09/23 03:53:33 UTC

[shardingsphere] branch master updated: resolve getConnection error (#21134)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a9692693725 resolve getConnection error (#21134)
a9692693725 is described below

commit a96926937258d6a351cd293a539c32d1393c4619
Author: natehuang <na...@tencent.com>
AuthorDate: Fri Sep 23 11:53:25 2022 +0800

    resolve getConnection error (#21134)
---
 .../communication/jdbc/connection/JDBCBackendConnection.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
index 8a09412f082..ba5260f66f2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/connection/JDBCBackendConnection.java
@@ -70,7 +70,7 @@ public final class JDBCBackendConnection implements BackendConnection<Void>, Exe
         Preconditions.checkNotNull(connectionSession.getDatabaseName(), "Current database name is null.");
         Collection<Connection> connections;
         synchronized (cachedConnections) {
-            connections = cachedConnections.get(connectionSession.getDatabaseName() + "." + dataSourceName);
+            connections = cachedConnections.get(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName);
         }
         List<Connection> result;
         if (connections.size() >= connectionSize) {
@@ -81,19 +81,19 @@ public final class JDBCBackendConnection implements BackendConnection<Void>, Exe
             List<Connection> newConnections = createNewConnections(dataSourceName, connectionSize - connections.size(), connectionMode);
             result.addAll(newConnections);
             synchronized (cachedConnections) {
-                cachedConnections.putAll(connectionSession.getDatabaseName() + "." + dataSourceName, newConnections);
+                cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, newConnections);
             }
         } else {
             result = createNewConnections(dataSourceName, connectionSize, connectionMode);
             synchronized (cachedConnections) {
-                cachedConnections.putAll(connectionSession.getDatabaseName() + "." + dataSourceName, result);
+                cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + "." + dataSourceName, result);
             }
         }
         return result;
     }
     
     private List<Connection> createNewConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode) throws SQLException {
-        List<Connection> result = ProxyContext.getInstance().getBackendDataSource().getConnections(connectionSession.getDatabaseName(), dataSourceName, connectionSize, connectionMode);
+        List<Connection> result = ProxyContext.getInstance().getBackendDataSource().getConnections(connectionSession.getDatabaseName().toLowerCase(), dataSourceName, connectionSize, connectionMode);
         setSessionVariablesIfNecessary(result);
         for (Connection each : result) {
             replayTransactionOption(each);
@@ -157,7 +157,7 @@ public final class JDBCBackendConnection implements BackendConnection<Void>, Exe
     @Override
     public Collection<String> getDataSourceNamesOfCachedConnections() {
         Collection<String> result = new ArrayList<>(cachedConnections.size());
-        String databaseName = connectionSession.getDatabaseName();
+        String databaseName = connectionSession.getDatabaseName().toLowerCase();
         for (String each : cachedConnections.keySet()) {
             String[] split = each.split("\\.", 2);
             String cachedDatabaseName = split[0];