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 78afabeb277 Remove useless OnlineDatabaseConnectionManager and 
AnalyzeDatabaseConnectionManager, add databaseName parameter in getConnections 
method (#31699)
78afabeb277 is described below

commit 78afabeb2772222f7536f7234e572de4b34651cb
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Tue Jun 18 08:04:48 2024 +0800

    Remove useless OnlineDatabaseConnectionManager and 
AnalyzeDatabaseConnectionManager, add databaseName parameter in getConnections 
method (#31699)
    
    * Remove useless OnlineDatabaseConnectionManager and 
AnalyzeDatabaseConnectionManager, add databaseName parameter in getConnections 
method
    
    * revert it-env.props
    
    * optimize code style
    
    * refactor getConnections logic
    
    * refactor getConnections logic
    
    * fix checkstyle
---
 .../prepare/AbstractExecutionPrepareEngine.java    | 13 +++---
 .../sql/prepare/ExecutionPrepareEngine.java        |  6 ++-
 .../prepare/driver/DatabaseConnectionManager.java  |  3 +-
 .../driver/DriverExecutionPrepareEngine.java       |  4 +-
 .../driver/OnlineDatabaseConnectionManager.java    | 26 ------------
 .../sql/prepare/raw/RawExecutionPrepareEngine.java |  2 +-
 .../DriverExecuteBatchExecutor.java                |  2 +-
 .../jdbc/DriverJDBCPushDownExecuteExecutor.java    |  2 +-
 .../DriverJDBCPushDownExecuteQueryExecutor.java    |  2 +-
 .../DriverJDBCPushDownExecuteUpdateExecutor.java   |  2 +-
 .../raw/DriverRawPushDownExecuteExecutor.java      |  3 +-
 .../raw/DriverRawPushDownExecuteQueryExecutor.java |  2 +-
 .../DriverRawPushDownExecuteUpdateExecutor.java    |  2 +-
 .../DriverDatabaseConnectionManager.java           | 35 ++++++++--------
 .../DriverDatabaseConnectionManagerTest.java       | 46 +++++++++++-----------
 .../connection/ShardingSphereConnectionTest.java   | 12 +++---
 .../datasource/ShardingSphereDataSourceTest.java   |  3 +-
 .../enumerable/EnumerableScanExecutor.java         |  8 ++--
 .../traffic/executor/TrafficExecutor.java          |  2 +-
 .../connector/ProxyDatabaseConnectionManager.java  | 23 +++++------
 .../proxy/backend/connector/ProxySQLExecutor.java  | 12 +++---
 .../ProxyDatabaseConnectionManagerTest.java        | 26 ++++++------
 .../text/query/MySQLMultiStatementsHandler.java    |  2 +-
 .../query/MySQLMultiStatementsHandlerTest.java     |  2 +-
 .../bind/OpenGaussComBatchBindExecutorTest.java    |  2 +-
 .../PostgreSQLBatchedStatementsExecutor.java       |  2 +-
 .../describe/PostgreSQLComDescribeExecutor.java    |  2 +-
 ...egatedBatchedStatementsCommandExecutorTest.java |  2 +-
 .../PostgreSQLBatchedStatementsExecutorTest.java   |  2 +-
 .../PostgreSQLComDescribeExecutorTest.java         |  2 +-
 30 files changed, 118 insertions(+), 134 deletions(-)

diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/AbstractExecutionPrepareEngine.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/AbstractExecutionPrepareEngine.java
index 7519f521863..ce97cb8e323 100644
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/AbstractExecutionPrepareEngine.java
+++ 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/AbstractExecutionPrepareEngine.java
@@ -54,20 +54,20 @@ public abstract class AbstractExecutionPrepareEngine<T> 
implements ExecutionPrep
     }
     
     @Override
-    public final ExecutionGroupContext<T> prepare(final RouteContext 
routeContext, final Collection<ExecutionUnit> executionUnits,
+    public final ExecutionGroupContext<T> prepare(final String databaseName, 
final RouteContext routeContext, final Collection<ExecutionUnit> executionUnits,
                                                   final 
ExecutionGroupReportContext reportContext) throws SQLException {
-        return prepare(routeContext, Collections.emptyMap(), executionUnits, 
reportContext);
+        return prepare(databaseName, routeContext, Collections.emptyMap(), 
executionUnits, reportContext);
     }
     
     @Override
-    public final ExecutionGroupContext<T> prepare(final RouteContext 
routeContext, final Map<String, Integer> connectionOffsets, final 
Collection<ExecutionUnit> executionUnits,
-                                                  final 
ExecutionGroupReportContext reportContext) throws SQLException {
+    public final ExecutionGroupContext<T> prepare(final String databaseName, 
final RouteContext routeContext, final Map<String, Integer> connectionOffsets,
+                                                  final 
Collection<ExecutionUnit> executionUnits, final ExecutionGroupReportContext 
reportContext) throws SQLException {
         Collection<ExecutionGroup<T>> result = new LinkedList<>();
         for (Entry<String, List<ExecutionUnit>> entry : 
aggregateExecutionUnitGroups(executionUnits).entrySet()) {
             String dataSourceName = entry.getKey();
             List<List<ExecutionUnit>> executionUnitGroups = 
group(entry.getValue());
             ConnectionMode connectionMode = maxConnectionsSizePerQuery < 
entry.getValue().size() ? ConnectionMode.CONNECTION_STRICTLY : 
ConnectionMode.MEMORY_STRICTLY;
-            result.addAll(group(dataSourceName, 
connectionOffsets.getOrDefault(dataSourceName, 0), executionUnitGroups, 
connectionMode));
+            result.addAll(group(databaseName, dataSourceName, 
connectionOffsets.getOrDefault(dataSourceName, 0), executionUnitGroups, 
connectionMode));
         }
         return decorate(routeContext, result, reportContext);
     }
@@ -77,7 +77,8 @@ public abstract class AbstractExecutionPrepareEngine<T> 
implements ExecutionPrep
         return Lists.partition(sqlUnits, desiredPartitionSize);
     }
     
-    protected abstract List<ExecutionGroup<T>> group(String dataSourceName, 
int connectionOffset, List<List<ExecutionUnit>> executionUnitGroups, 
ConnectionMode connectionMode) throws SQLException;
+    protected abstract List<ExecutionGroup<T>> group(String databaseName, 
String dataSourceName, int connectionOffset, List<List<ExecutionUnit>> 
executionUnitGroups,
+                                                     ConnectionMode 
connectionMode) throws SQLException;
     
     private Map<String, List<ExecutionUnit>> 
aggregateExecutionUnitGroups(final Collection<ExecutionUnit> executionUnits) {
         Map<String, List<ExecutionUnit>> result = new TreeMap<>();
diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareEngine.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareEngine.java
index a33317a8017..5d8e3e46e3e 100644
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareEngine.java
+++ 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/ExecutionPrepareEngine.java
@@ -36,17 +36,19 @@ public interface ExecutionPrepareEngine<T> {
     /**
      * Prepare to execute.
      *
+     * @param databaseName database name
      * @param routeContext route context
      * @param executionUnits execution units
      * @param reportContext report context
      * @return execution group context
      * @throws SQLException SQL exception
      */
-    ExecutionGroupContext<T> prepare(RouteContext routeContext, 
Collection<ExecutionUnit> executionUnits, ExecutionGroupReportContext 
reportContext) throws SQLException;
+    ExecutionGroupContext<T> prepare(String databaseName, RouteContext 
routeContext, Collection<ExecutionUnit> executionUnits, 
ExecutionGroupReportContext reportContext) throws SQLException;
     
     /**
      * Prepare to execute.
      *
+     * @param databaseName database name
      * @param routeContext route context
      * @param connectionOffsets execution offsets
      * @param executionUnits execution units
@@ -54,6 +56,6 @@ public interface ExecutionPrepareEngine<T> {
      * @return execution group context
      * @throws SQLException SQL exception
      */
-    ExecutionGroupContext<T> prepare(RouteContext routeContext, Map<String, 
Integer> connectionOffsets, Collection<ExecutionUnit> executionUnits,
+    ExecutionGroupContext<T> prepare(String databaseName, RouteContext 
routeContext, Map<String, Integer> connectionOffsets, Collection<ExecutionUnit> 
executionUnits,
                                      ExecutionGroupReportContext 
reportContext) throws SQLException;
 }
diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DatabaseConnectionManager.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DatabaseConnectionManager.java
index 2dacb7f81c2..b4c99a4c896 100644
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DatabaseConnectionManager.java
+++ 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DatabaseConnectionManager.java
@@ -32,6 +32,7 @@ public interface DatabaseConnectionManager<C> {
     /**
      * Get database connections.
      *
+     * @param databaseName database name
      * @param dataSourceName data source name
      * @param connectionOffset connection offset
      * @param connectionSize connection size
@@ -39,5 +40,5 @@ public interface DatabaseConnectionManager<C> {
      * @return database connections
      * @throws SQLException SQL exception
      */
-    List<C> getConnections(String dataSourceName, int connectionOffset, int 
connectionSize, ConnectionMode connectionMode) throws SQLException;
+    List<C> getConnections(String databaseName, String dataSourceName, int 
connectionOffset, int connectionSize, ConnectionMode connectionMode) throws 
SQLException;
 }
diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
index 4e097b0dacc..17dd4851ea1 100644
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
+++ 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/DriverExecutionPrepareEngine.java
@@ -88,10 +88,10 @@ public final class DriverExecutionPrepareEngine<T extends 
DriverExecutionUnit<?>
     }
     
     @Override
-    protected List<ExecutionGroup<T>> group(final String dataSourceName, final 
int connectionOffset, final List<List<ExecutionUnit>> executionUnitGroups,
+    protected List<ExecutionGroup<T>> group(final String databaseName, final 
String dataSourceName, final int connectionOffset, final 
List<List<ExecutionUnit>> executionUnitGroups,
                                             final ConnectionMode 
connectionMode) throws SQLException {
         List<ExecutionGroup<T>> result = new LinkedList<>();
-        List<C> connections = 
databaseConnectionManager.getConnections(dataSourceName, connectionOffset, 
executionUnitGroups.size(), connectionMode);
+        List<C> connections = 
databaseConnectionManager.getConnections(databaseName, dataSourceName, 
connectionOffset, executionUnitGroups.size(), connectionMode);
         int count = 0;
         for (List<ExecutionUnit> each : executionUnitGroups) {
             result.add(createExecutionGroup(dataSourceName, each, 
connections.get(count++), connectionMode));
diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/OnlineDatabaseConnectionManager.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/OnlineDatabaseConnectionManager.java
deleted file mode 100644
index 6c27a58f30c..00000000000
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/OnlineDatabaseConnectionManager.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.executor.sql.prepare.driver;
-
-/**
- * Online database connection manager.
- *
- * @param <C> type of database connection
- */
-public interface OnlineDatabaseConnectionManager<C> extends 
DatabaseConnectionManager<C> {
-}
diff --git 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/raw/RawExecutionPrepareEngine.java
 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/raw/RawExecutionPrepareEngine.java
index 9215faa2f25..dfc50aceb15 100644
--- 
a/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/raw/RawExecutionPrepareEngine.java
+++ 
b/infra/executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/raw/RawExecutionPrepareEngine.java
@@ -39,7 +39,7 @@ public final class RawExecutionPrepareEngine extends 
AbstractExecutionPrepareEng
     }
     
     @Override
-    protected List<ExecutionGroup<RawSQLExecutionUnit>> group(final String 
dataSourceName, final int connectionOffset, final List<List<ExecutionUnit>> 
executionUnitGroups,
+    protected List<ExecutionGroup<RawSQLExecutionUnit>> group(final String 
databaseName, final String dataSourceName, final int connectionOffset, final 
List<List<ExecutionUnit>> executionUnitGroups,
                                                               final 
ConnectionMode connectionMode) throws SQLException {
         return executionUnitGroups.stream().map(each -> 
createExecutionGroup(each, connectionMode)).collect(Collectors.toList());
     }
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/batch/preparedstatement/DriverExecuteBatchExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/batch/preparedstatement/DriverExecuteBatchExecutor.java
index 9eca9c2a1de..7a06dd6dfa7 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/batch/preparedstatement/DriverExecuteBatchExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/batch/preparedstatement/DriverExecuteBatchExecutor.java
@@ -152,7 +152,7 @@ public final class DriverExecuteBatchExecutor {
             executionUnits.add(executionUnit);
         }
         batchExecutor.init(prepareEngine
-                .prepare(executionContext.getRouteContext(), executionUnits, 
new ExecutionGroupReportContext(connection.getProcessId(), database.getName(), 
new Grantee("", ""))));
+                .prepare(database.getName(), 
executionContext.getRouteContext(), executionUnits, new 
ExecutionGroupReportContext(connection.getProcessId(), database.getName(), new 
Grantee("", ""))));
         setBatchParameters(replayCallback);
     }
     
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteExecutor.java
index 65542488ff8..2471775b17b 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteExecutor.java
@@ -93,7 +93,7 @@ public final class DriverJDBCPushDownExecuteExecutor {
     @SuppressWarnings({"rawtypes", "unchecked"})
     private boolean doExecute(final ShardingSphereDatabase database, final 
ExecutionContext executionContext, final 
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
                               final StatementExecuteCallback executeCallback, 
final StatementAddCallback addCallback, final StatementReplayCallback 
replayCallback) throws SQLException {
-        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(
+        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(database.getName(),
                 executionContext.getRouteContext(), 
executionContext.getExecutionUnits(), new 
ExecutionGroupReportContext(connection.getProcessId(), database.getName(), 
grantee));
         for (ExecutionGroup<JDBCExecutionUnit> each : 
executionGroupContext.getInputGroups()) {
             addCallback.add(getStatements(each), 
JDBCDriverType.PREPARED_STATEMENT.equals(prepareEngine.getType()) ? 
getParameterSets(each) : Collections.emptyList());
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteQueryExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteQueryExecutor.java
index 6337ca1cf75..5452cb22398 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteQueryExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteQueryExecutor.java
@@ -107,7 +107,7 @@ public final class DriverJDBCPushDownExecuteQueryExecutor {
                                               final StatementAddCallback 
addCallback, final StatementReplayCallback replayCallback) throws SQLException {
         statements.clear();
         ExecutionContext executionContext = new 
KernelProcessor().generateExecutionContext(queryContext, database, 
globalRuleMetaData, props, connectionContext);
-        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(executionContext.getRouteContext(), 
executionContext.getExecutionUnits(),
+        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(database.getName(), executionContext.getRouteContext(), 
executionContext.getExecutionUnits(),
                 new ExecutionGroupReportContext(processId, database.getName(), 
grantee));
         for (ExecutionGroup<JDBCExecutionUnit> each : 
executionGroupContext.getInputGroups()) {
             Collection<Statement> statements = getStatements(each);
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteUpdateExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteUpdateExecutor.java
index baf4600aa6d..48e80987fd7 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteUpdateExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/jdbc/DriverJDBCPushDownExecuteUpdateExecutor.java
@@ -97,7 +97,7 @@ public final class DriverJDBCPushDownExecuteUpdateExecutor {
     @SuppressWarnings({"rawtypes", "unchecked"})
     private int doExecuteUpdate(final ShardingSphereDatabase database, final 
ExecutionContext executionContext, final 
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine,
                                 final StatementExecuteUpdateCallback 
updateCallback, final StatementAddCallback addCallback, final 
StatementReplayCallback replayCallback) throws SQLException {
-        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(
+        ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext = 
prepareEngine.prepare(database.getName(),
                 executionContext.getRouteContext(), 
executionContext.getExecutionUnits(), new 
ExecutionGroupReportContext(processId, database.getName(), grantee));
         for (ExecutionGroup<JDBCExecutionUnit> each : 
executionGroupContext.getInputGroups()) {
             addCallback.add(getStatements(each), 
JDBCDriverType.PREPARED_STATEMENT.equals(prepareEngine.getType()) ? 
getParameterSets(each) : Collections.emptyList());
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteExecutor.java
index 8f707b7e438..a4efadc0009 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteExecutor.java
@@ -59,7 +59,8 @@ public final class DriverRawPushDownExecuteExecutor {
     public boolean execute(final ShardingSphereDatabase database, final 
ExecutionContext executionContext) throws SQLException {
         int maxConnectionsSizePerQuery = 
metaData.getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
         ExecutionGroupContext<RawSQLExecutionUnit> executionGroupContext = new 
RawExecutionPrepareEngine(maxConnectionsSizePerQuery, 
database.getRuleMetaData().getRules())
-                .prepare(executionContext.getRouteContext(), 
executionContext.getExecutionUnits(), new 
ExecutionGroupReportContext(connection.getProcessId(), database.getName(), 
grantee));
+                .prepare(database.getName(), 
executionContext.getRouteContext(), executionContext.getExecutionUnits(),
+                        new 
ExecutionGroupReportContext(connection.getProcessId(), database.getName(), 
grantee));
         return rawExecutor.execute(executionGroupContext, 
executionContext.getQueryContext(), new 
RawSQLExecutorCallback()).iterator().next() instanceof QueryResult;
     }
 }
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteQueryExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteQueryExecutor.java
index dea22b61385..6ac20f196c4 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteQueryExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteQueryExecutor.java
@@ -96,7 +96,7 @@ public final class DriverRawPushDownExecuteQueryExecutor {
     
     private ExecutionGroupContext<RawSQLExecutionUnit> 
createRawExecutionGroupContext(final ShardingSphereDatabase database, final 
ExecutionContext executionContext) throws SQLException {
         int maxConnectionsSizePerQuery = 
props.<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
-        return new RawExecutionPrepareEngine(maxConnectionsSizePerQuery, 
database.getRuleMetaData().getRules()).prepare(
+        return new RawExecutionPrepareEngine(maxConnectionsSizePerQuery, 
database.getRuleMetaData().getRules()).prepare(database.getName(),
                 executionContext.getRouteContext(), 
executionContext.getExecutionUnits(), new 
ExecutionGroupReportContext(processId, database.getName(), grantee));
     }
 }
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteUpdateExecutor.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteUpdateExecutor.java
index df84ae3f51a..ed7c4f4227f 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteUpdateExecutor.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/pushdown/raw/DriverRawPushDownExecuteUpdateExecutor.java
@@ -78,7 +78,7 @@ public final class DriverRawPushDownExecuteUpdateExecutor {
     
     private ExecutionGroupContext<RawSQLExecutionUnit> 
createRawExecutionGroupContext(final ShardingSphereDatabase database, final 
ExecutionContext executionContext) throws SQLException {
         int maxConnectionsSizePerQuery = 
props.<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
-        return new RawExecutionPrepareEngine(maxConnectionsSizePerQuery, 
database.getRuleMetaData().getRules()).prepare(
+        return new RawExecutionPrepareEngine(maxConnectionsSizePerQuery, 
database.getRuleMetaData().getRules()).prepare(database.getName(),
                 executionContext.getRouteContext(), 
executionContext.getExecutionUnits(), new 
ExecutionGroupReportContext(processId, database.getName(), grantee));
     }
 }
diff --git 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
index 3caa18ede4a..88b89c7cb48 100644
--- 
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
+++ 
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCre
 import 
org.apache.shardingsphere.infra.datasource.pool.props.domain.DataSourcePoolProperties;
 import 
org.apache.shardingsphere.infra.exception.kernel.connection.OverallConnectionNotEnoughException;
 import 
org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.OnlineDatabaseConnectionManager;
+import 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConnectionManager;
 import org.apache.shardingsphere.infra.instance.metadata.InstanceMetaData;
 import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
 import 
org.apache.shardingsphere.infra.instance.metadata.proxy.ProxyInstanceMetaData;
@@ -62,9 +62,9 @@ import java.util.concurrent.ThreadLocalRandom;
 /**
  * Database connection manager of ShardingSphere-JDBC.
  */
-public final class DriverDatabaseConnectionManager implements 
OnlineDatabaseConnectionManager<Connection>, AutoCloseable {
+public final class DriverDatabaseConnectionManager implements 
DatabaseConnectionManager<Connection>, AutoCloseable {
     
-    private final String databaseName;
+    private final String defaultDatabaseName;
     
     private final ContextManager contextManager;
     
@@ -83,14 +83,14 @@ public final class DriverDatabaseConnectionManager 
implements OnlineDatabaseConn
     
     private final ForceExecuteTemplate<Connection> forceExecuteTemplate = new 
ForceExecuteTemplate<>();
     
-    public DriverDatabaseConnectionManager(final String databaseName, final 
ContextManager contextManager) {
-        this.databaseName = databaseName;
+    public DriverDatabaseConnectionManager(final String defaultDatabaseName, 
final ContextManager contextManager) {
+        this.defaultDatabaseName = defaultDatabaseName;
         this.contextManager = contextManager;
-        physicalDataSourceMap = getPhysicalDataSourceMap(databaseName, 
contextManager);
-        trafficDataSourceMap = getTrafficDataSourceMap(databaseName, 
contextManager);
+        physicalDataSourceMap = getPhysicalDataSourceMap(defaultDatabaseName, 
contextManager);
+        trafficDataSourceMap = getTrafficDataSourceMap(defaultDatabaseName, 
contextManager);
         dataSourceMap = getDataSourceMap();
         connectionContext = new ConnectionContext(cachedConnections::keySet);
-        connectionContext.setCurrentDatabase(databaseName);
+        connectionContext.setCurrentDatabase(defaultDatabaseName);
     }
     
     private Map<String, DataSource> getPhysicalDataSourceMap(final String 
databaseName, final ContextManager contextManager) {
@@ -349,18 +349,19 @@ public final class DriverDatabaseConnectionManager 
implements OnlineDatabaseConn
      */
     public Connection getRandomConnection() throws SQLException {
         String[] databaseAndDataSourceName = 
getRandomPhysicalDatabaseAndDataSourceName();
-        return getConnections(databaseAndDataSourceName[0], 
databaseAndDataSourceName[1], 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
+        return getConnections0(databaseAndDataSourceName[0], 
databaseAndDataSourceName[1], 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
     }
     
     @Override
-    public List<Connection> getConnections(final String dataSourceName, final 
int connectionOffset, final int connectionSize, final ConnectionMode 
connectionMode) throws SQLException {
-        return 
getConnections(connectionContext.getDatabaseName().orElse(databaseName), 
dataSourceName, connectionOffset, connectionSize, connectionMode);
+    public List<Connection> getConnections(final String databaseName, final 
String dataSourceName, final int connectionOffset, final int connectionSize,
+                                           final ConnectionMode 
connectionMode) throws SQLException {
+        return getConnections0(databaseName, dataSourceName, connectionOffset, 
connectionSize, connectionMode);
     }
     
-    private List<Connection> getConnections(final String currentDatabaseName, 
final String dataSourceName, final int connectionOffset, final int 
connectionSize,
-                                            final ConnectionMode 
connectionMode) throws SQLException {
-        String cacheKey = getKey(currentDatabaseName, dataSourceName);
-        DataSource dataSource = databaseName.equals(currentDatabaseName) ? 
dataSourceMap.get(cacheKey) : 
contextManager.getStorageUnits(currentDatabaseName).get(dataSourceName).getDataSource();
+    private List<Connection> getConnections0(final String databaseName, final 
String dataSourceName, final int connectionOffset, final int connectionSize,
+                                             final ConnectionMode 
connectionMode) throws SQLException {
+        String cacheKey = getKey(databaseName, dataSourceName);
+        DataSource dataSource = defaultDatabaseName.equals(databaseName) ? 
dataSourceMap.get(cacheKey) : 
contextManager.getStorageUnits(databaseName).get(dataSourceName).getDataSource();
         Preconditions.checkNotNull(dataSource, "Missing the data source name: 
'%s'", dataSourceName);
         Collection<Connection> connections;
         synchronized (cachedConnections) {
@@ -371,7 +372,7 @@ public final class DriverDatabaseConnectionManager 
implements OnlineDatabaseConn
         if (connections.size() >= maxConnectionSize) {
             result = new ArrayList<>(connections).subList(connectionOffset, 
maxConnectionSize);
         } else if (connections.isEmpty()) {
-            Collection<Connection> newConnections = 
createConnections(currentDatabaseName, dataSourceName, dataSource, 
maxConnectionSize, connectionMode);
+            Collection<Connection> newConnections = 
createConnections(databaseName, dataSourceName, dataSource, maxConnectionSize, 
connectionMode);
             result = new ArrayList<>(newConnections).subList(connectionOffset, 
maxConnectionSize);
             synchronized (cachedConnections) {
                 cachedConnections.putAll(cacheKey, newConnections);
@@ -379,7 +380,7 @@ public final class DriverDatabaseConnectionManager 
implements OnlineDatabaseConn
         } else {
             List<Connection> allConnections = new 
ArrayList<>(maxConnectionSize);
             allConnections.addAll(connections);
-            Collection<Connection> newConnections = 
createConnections(currentDatabaseName, dataSourceName, dataSource, 
maxConnectionSize - connections.size(), connectionMode);
+            Collection<Connection> newConnections = 
createConnections(databaseName, dataSourceName, dataSource, maxConnectionSize - 
connections.size(), connectionMode);
             allConnections.addAll(newConnections);
             result = allConnections.subList(connectionOffset, 
maxConnectionSize);
             synchronized (cachedConnections) {
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
index 9391da3a394..1799275797a 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManagerTest.java
@@ -132,12 +132,12 @@ class DriverDatabaseConnectionManagerTest {
     @Test
     void assertGetRandomPhysicalDataSourceNameFromContextManager() {
         String actual = 
databaseConnectionManager.getRandomPhysicalDataSourceName();
-        assertTrue(Arrays.asList("ds", "invalid_ds").contains(actual));
+        assertTrue(Arrays.asList(DefaultDatabase.LOGIC_NAME, "ds", 
"invalid_ds").contains(actual));
     }
     
     @Test
     void assertGetRandomPhysicalDataSourceNameFromCache() throws SQLException {
-        databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
+        databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
         
assertThat(databaseConnectionManager.getRandomPhysicalDataSourceName(), 
is("ds"));
         
assertThat(databaseConnectionManager.getRandomPhysicalDataSourceName(), 
is("ds"));
         
assertThat(databaseConnectionManager.getRandomPhysicalDataSourceName(), 
is("ds"));
@@ -145,24 +145,24 @@ class DriverDatabaseConnectionManagerTest {
     
     @Test
     void assertGetConnection() throws SQLException {
-        assertThat(databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                is(databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY),
+                
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 
0, 1, ConnectionMode.MEMORY_STRICTLY)));
     }
     
     @Test
     void assertGetConnectionWithConnectionOffset() throws SQLException {
-        assertThat(databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                is(databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY)));
-        assertThat(databaseConnectionManager.getConnections("ds", 1, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                is(databaseConnectionManager.getConnections("ds", 1, 1, 
ConnectionMode.MEMORY_STRICTLY)));
-        assertThat(databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                not(databaseConnectionManager.getConnections("ds", 1, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY),
+                
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 
0, 1, ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 1, 1, ConnectionMode.MEMORY_STRICTLY),
+                
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 
1, 1, ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY),
+                
not(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 
1, 1, ConnectionMode.MEMORY_STRICTLY)));
     }
     
     @Test
     void assertGetConnectionWhenConfigTrafficRule() throws SQLException {
-        List<Connection> actual = 
databaseConnectionManager.getConnections("127.0.0.1@3307", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
-        assertThat(actual, 
is(databaseConnectionManager.getConnections("127.0.0.1@3307", 0, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"127.0.0.1@3307", 0, 1, ConnectionMode.MEMORY_STRICTLY);
+        assertThat(actual, 
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"127.0.0.1@3307", 0, 1, ConnectionMode.MEMORY_STRICTLY)));
         assertThat(actual.size(), is(1));
         assertThat(actual.get(0).getMetaData().getUserName(), is("root"));
         assertThat(actual.get(0).getMetaData().getURL(), 
is("jdbc:mysql://127.0.0.1:3307/logic_db?useSSL=false"));
@@ -170,16 +170,16 @@ class DriverDatabaseConnectionManagerTest {
     
     @Test
     void assertGetConnectionsWhenAllInCache() throws SQLException {
-        Connection expected = databaseConnectionManager.getConnections("ds", 
0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
-        List<Connection> actual = 
databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
+        Connection expected = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY).get(0);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 0, 
1, ConnectionMode.CONNECTION_STRICTLY);
         assertThat(actual.size(), is(1));
         assertThat(actual.get(0), is(expected));
     }
     
     @Test
     void assertGetConnectionsWhenConfigTrafficRuleAndAllInCache() throws 
SQLException {
-        Connection expected = 
databaseConnectionManager.getConnections("127.0.0.1@3307", 0, 1, 
ConnectionMode.MEMORY_STRICTLY).get(0);
-        List<Connection> actual = 
databaseConnectionManager.getConnections("127.0.0.1@3307", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
+        Connection expected = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"127.0.0.1@3307", 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"127.0.0.1@3307", 0, 1, ConnectionMode.CONNECTION_STRICTLY);
         assertThat(actual.size(), is(1));
         assertThat(actual.get(0), is(expected));
         assertThat(actual.get(0).getMetaData().getUserName(), is("root"));
@@ -188,13 +188,13 @@ class DriverDatabaseConnectionManagerTest {
     
     @Test
     void assertGetConnectionsWhenEmptyCache() throws SQLException {
-        List<Connection> actual = 
databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actual.size(), is(1));
     }
     
     @Test
     void assertGetConnectionsWhenConfigTrafficRuleAndEmptyCache() throws 
SQLException {
-        List<Connection> actual = 
databaseConnectionManager.getConnections("127.0.0.1@3307", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"127.0.0.1@3307", 0, 1, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actual.size(), is(1));
         assertThat(actual.get(0).getMetaData().getUserName(), is("root"));
         assertThat(actual.get(0).getMetaData().getURL(), 
is("jdbc:mysql://127.0.0.1:3307/logic_db?useSSL=false"));
@@ -202,21 +202,21 @@ class DriverDatabaseConnectionManagerTest {
     
     @Test
     void assertGetConnectionsWhenPartInCacheWithMemoryStrictlyMode() throws 
SQLException {
-        databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
-        List<Connection> actual = 
databaseConnectionManager.getConnections("ds", 0, 3, 
ConnectionMode.MEMORY_STRICTLY);
+        databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 0, 
3, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actual.size(), is(3));
     }
     
     @Test
     void assertGetConnectionsWhenPartInCacheWithConnectionStrictlyMode() 
throws SQLException {
-        databaseConnectionManager.getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY);
-        List<Connection> actual = 
databaseConnectionManager.getConnections("ds", 0, 3, 
ConnectionMode.CONNECTION_STRICTLY);
+        databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actual = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds", 0, 
3, ConnectionMode.CONNECTION_STRICTLY);
         assertThat(actual.size(), is(3));
     }
     
     @Test
     void assertGetConnectionsWhenConnectionCreateFailed() {
-        SQLException ex = assertThrows(SQLException.class, () -> 
databaseConnectionManager.getConnections("invalid_ds", 0, 3, 
ConnectionMode.CONNECTION_STRICTLY));
+        SQLException ex = assertThrows(SQLException.class, () -> 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"invalid_ds", 0, 3, ConnectionMode.CONNECTION_STRICTLY));
         assertThat(ex.getMessage(), is("Can not get 3 connections one time, 
partition succeed connection(0) have released. "
                 + "Please consider increasing the 'maxPoolSize' of the data 
sources or decreasing the 'max-connections-size-per-query' in properties."));
     }
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
index 90c7164021a..c1fc69673a6 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnectionTest.java
@@ -57,7 +57,7 @@ class ShardingSphereConnectionTest {
     void assertSetAutoCommitWithLocalTransaction() throws SQLException {
         Connection physicalConnection = mock(Connection.class);
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, 
mockContextManager(physicalConnection))) {
-            connection.getDatabaseConnectionManager().getConnections("ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY);
+            
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
             connection.setAutoCommit(true);
             assertTrue(connection.getAutoCommit());
         }
@@ -81,7 +81,7 @@ class ShardingSphereConnectionTest {
     void assertCommitWithLocalTransaction() throws SQLException {
         Connection physicalConnection = mock(Connection.class);
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, 
mockContextManager(physicalConnection))) {
-            connection.getDatabaseConnectionManager().getConnections("ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY);
+            
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
             connection.setAutoCommit(false);
             assertFalse(connection.getAutoCommit());
             
assertTrue(connection.getDatabaseConnectionManager().getConnectionContext().getTransactionContext().isInTransaction());
@@ -114,7 +114,7 @@ class ShardingSphereConnectionTest {
     void assertRollbackWithLocalTransaction() throws SQLException {
         Connection physicalConnection = mock(Connection.class);
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, 
mockContextManager(physicalConnection))) {
-            connection.getDatabaseConnectionManager().getConnections("ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY);
+            
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
             connection.setAutoCommit(false);
             assertFalse(connection.getAutoCommit());
             connection.rollback();
@@ -158,7 +158,7 @@ class ShardingSphereConnectionTest {
     @Test
     void assertIsInvalid() throws SQLException {
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
-            connection.getDatabaseConnectionManager().getConnections("ds", 0, 
1, ConnectionMode.MEMORY_STRICTLY);
+            
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
             assertFalse(connection.isValid(0));
         }
     }
@@ -167,7 +167,7 @@ class ShardingSphereConnectionTest {
     void assertSetReadOnly() throws SQLException {
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
             assertFalse(connection.isReadOnly());
-            Connection physicalConnection = 
connection.getDatabaseConnectionManager().getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY).get(0);
+            Connection physicalConnection = 
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
             connection.setReadOnly(true);
             assertTrue(connection.isReadOnly());
             verify(physicalConnection).setReadOnly(true);
@@ -185,7 +185,7 @@ class ShardingSphereConnectionTest {
     @Test
     void assertSetTransactionIsolation() throws SQLException {
         try (ShardingSphereConnection connection = new 
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
-            Connection physicalConnection = 
connection.getDatabaseConnectionManager().getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY).get(0);
+            Connection physicalConnection = 
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
 "ds", 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
             
connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
             
verify(physicalConnection).setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
         }
diff --git 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
index 6b1c8fabaa7..a47291d9b47 100644
--- 
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
+++ 
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
@@ -95,7 +95,8 @@ class ShardingSphereDataSourceTest {
         Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
         
when(connection.getMetaData().getURL()).thenReturn("jdbc:mock://127.0.0.1/foo_ds");
         try (ShardingSphereDataSource actual = 
createShardingSphereDataSource(new MockedDataSource(connection))) {
-            assertThat(((ShardingSphereConnection) actual.getConnection("", 
"")).getDatabaseConnectionManager().getConnections("ds", 0, 1, 
ConnectionMode.MEMORY_STRICTLY).get(0), is(connection));
+            assertThat(((ShardingSphereConnection) actual.getConnection("", 
"")).getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME, 
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY)
+                    .get(0), is(connection));
         }
     }
     
diff --git 
a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java
 
b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java
index ac3e6db64dd..15e9e1d976a 100644
--- 
a/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java
+++ 
b/kernel/sql-federation/executor/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerableScanExecutor.java
@@ -131,11 +131,11 @@ public final class EnumerableScanExecutor implements 
ScanExecutor {
             public Enumerator<Object> enumerator() {
                 computeConnectionOffsets(context);
                 // TODO pass grantee from proxy and jdbc adapter
-                ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext 
= prepareEngine.prepare(context.getRouteContext(), 
executorContext.getConnectionOffsets(), context.getExecutionUnits(),
-                        new 
ExecutionGroupReportContext(federationContext.getProcessId(), 
database.getName(), new Grantee("", "")));
+                ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext 
=
+                        prepareEngine.prepare(database.getName(), 
context.getRouteContext(), executorContext.getConnectionOffsets(), 
context.getExecutionUnits(),
+                                new 
ExecutionGroupReportContext(federationContext.getProcessId(), 
database.getName(), new Grantee("", "")));
                 setParameters(executionGroupContext.getInputGroups());
-                
ShardingSpherePreconditions.checkState(!ProcessRegistry.getInstance().get(federationContext.getProcessId()).isInterrupted(),
-                        SQLExecutionInterruptedException::new);
+                
ShardingSpherePreconditions.checkState(!ProcessRegistry.getInstance().get(federationContext.getProcessId()).isInterrupted(),
 SQLExecutionInterruptedException::new);
                 processEngine.executeSQL(executionGroupContext, 
federationContext.getQueryContext());
                 List<QueryResult> queryResults = 
jdbcExecutor.execute(executionGroupContext, 
callback).stream().map(QueryResult.class::cast).collect(Collectors.toList());
                 MergeEngine mergeEngine = new 
MergeEngine(federationContext.getMetaData().getGlobalRuleMetaData(), database, 
executorContext.getProps(), new ConnectionContext(Collections::emptySet));
diff --git 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/executor/TrafficExecutor.java
 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/executor/TrafficExecutor.java
index 56e42edf713..36c00d92d01 100644
--- 
a/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/executor/TrafficExecutor.java
+++ 
b/kernel/traffic/core/src/main/java/org/apache/shardingsphere/traffic/executor/TrafficExecutor.java
@@ -74,7 +74,7 @@ public final class TrafficExecutor implements AutoCloseable {
                                                          final 
DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine) 
throws SQLException {
         ExecutionUnit executionUnit = new ExecutionUnit(trafficInstanceId, new 
SQLUnit(queryContext.getSql(), queryContext.getParameters()));
         ExecutionGroupContext<JDBCExecutionUnit> context =
-                prepareEngine.prepare(new RouteContext(), 
Collections.singleton(executionUnit), new 
ExecutionGroupReportContext(processId, databaseName, new Grantee("", "")));
+                prepareEngine.prepare(databaseName, new RouteContext(), 
Collections.singleton(executionUnit), new 
ExecutionGroupReportContext(processId, databaseName, new Grantee("", "")));
         return context.getInputGroups().stream().flatMap(each -> 
each.getInputs().stream()).findFirst().orElseThrow(EmptyTrafficExecutionUnitException::new);
     }
     
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
index f5c3b3d3d71..457a577fda5 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManager.java
@@ -23,7 +23,7 @@ import com.google.common.collect.Multimap;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.OnlineDatabaseConnectionManager;
+import 
org.apache.shardingsphere.infra.executor.sql.prepare.driver.DatabaseConnectionManager;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import 
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ConnectionPostProcessor;
 import 
org.apache.shardingsphere.proxy.backend.connector.jdbc.connection.ResourceLock;
@@ -51,7 +51,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
  */
 @RequiredArgsConstructor
 @Getter
-public final class ProxyDatabaseConnectionManager implements 
OnlineDatabaseConnectionManager<Connection> {
+public final class ProxyDatabaseConnectionManager implements 
DatabaseConnectionManager<Connection> {
     
     private final ConnectionSession connectionSession;
     
@@ -70,31 +70,32 @@ public final class ProxyDatabaseConnectionManager 
implements OnlineDatabaseConne
     private final Collection<TransactionHook> transactionHooks = 
ShardingSphereServiceLoader.getServiceInstances(TransactionHook.class);
     
     @Override
-    public List<Connection> getConnections(final String dataSourceName, final 
int connectionOffset, final int connectionSize, final ConnectionMode 
connectionMode) throws SQLException {
-        Preconditions.checkNotNull(connectionSession.getDatabaseName(), 
"Current database name is null.");
+    public List<Connection> getConnections(final String databaseName, final 
String dataSourceName, final int connectionOffset, final int connectionSize,
+                                           final ConnectionMode 
connectionMode) throws SQLException {
+        Preconditions.checkNotNull(databaseName, "Current database name is 
null.");
         Collection<Connection> connections;
         synchronized (cachedConnections) {
-            connections = 
cachedConnections.get(connectionSession.getDatabaseName().toLowerCase() + "." + 
dataSourceName);
+            connections = cachedConnections.get(databaseName.toLowerCase() + 
"." + dataSourceName);
         }
         List<Connection> result;
         int maxConnectionSize = connectionOffset + connectionSize;
         if (connections.size() >= maxConnectionSize) {
             result = new ArrayList<>(connections).subList(connectionOffset, 
maxConnectionSize);
         } else if (connections.isEmpty()) {
-            Collection<Connection> newConnections = 
createNewConnections(dataSourceName, maxConnectionSize, connectionMode);
+            Collection<Connection> newConnections = 
createNewConnections(databaseName, dataSourceName, maxConnectionSize, 
connectionMode);
             result = new ArrayList<>(newConnections).subList(connectionOffset, 
maxConnectionSize);
             synchronized (cachedConnections) {
-                
cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + 
"." + dataSourceName, newConnections);
+                cachedConnections.putAll(databaseName.toLowerCase() + "." + 
dataSourceName, newConnections);
             }
             executeTransactionHooksAfterCreateConnections(result);
         } else {
             List<Connection> allConnections = new 
ArrayList<>(maxConnectionSize);
             allConnections.addAll(connections);
-            List<Connection> newConnections = 
createNewConnections(dataSourceName, maxConnectionSize - connections.size(), 
connectionMode);
+            List<Connection> newConnections = 
createNewConnections(databaseName, dataSourceName, maxConnectionSize - 
connections.size(), connectionMode);
             allConnections.addAll(newConnections);
             result = allConnections.subList(connectionOffset, 
maxConnectionSize);
             synchronized (cachedConnections) {
-                
cachedConnections.putAll(connectionSession.getDatabaseName().toLowerCase() + 
"." + dataSourceName, newConnections);
+                cachedConnections.putAll(databaseName.toLowerCase() + "." + 
dataSourceName, newConnections);
             }
         }
         return result;
@@ -108,8 +109,8 @@ public final class ProxyDatabaseConnectionManager 
implements OnlineDatabaseConne
         }
     }
     
-    private List<Connection> createNewConnections(final String dataSourceName, 
final int connectionSize, final ConnectionMode connectionMode) throws 
SQLException {
-        List<Connection> result = 
ProxyContext.getInstance().getBackendDataSource().getConnections(connectionSession.getDatabaseName().toLowerCase(),
 dataSourceName, connectionSize, connectionMode);
+    private List<Connection> createNewConnections(final String databaseName, 
final String dataSourceName, final int connectionSize, final ConnectionMode 
connectionMode) throws SQLException {
+        List<Connection> result = 
ProxyContext.getInstance().getBackendDataSource().getConnections(databaseName.toLowerCase(),
 dataSourceName, connectionSize, connectionMode);
         setSessionVariablesIfNecessary(result);
         for (Connection each : result) {
             replayTransactionOption(each);
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
index 441ce16663d..0939af72cb3 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/connector/ProxySQLExecutor.java
@@ -199,9 +199,10 @@ public final class ProxySQLExecutor {
         RawExecutionPrepareEngine prepareEngine = new 
RawExecutionPrepareEngine(maxConnectionsSizePerQuery, rules);
         ExecutionGroupContext<RawSQLExecutionUnit> executionGroupContext;
         try {
-            executionGroupContext = 
prepareEngine.prepare(executionContext.getRouteContext(), 
executionContext.getExecutionUnits(),
+            String databaseName = 
databaseConnectionManager.getConnectionSession().getDatabaseName();
+            executionGroupContext = prepareEngine.prepare(databaseName, 
executionContext.getRouteContext(), executionContext.getExecutionUnits(),
                     new 
ExecutionGroupReportContext(databaseConnectionManager.getConnectionSession().getProcessId(),
-                            
databaseConnectionManager.getConnectionSession().getDatabaseName(), 
databaseConnectionManager.getConnectionSession().getConnectionContext().getGrantee()));
+                            databaseName, 
databaseConnectionManager.getConnectionSession().getConnectionContext().getGrantee()));
         } catch (final SQLException ex) {
             return getSaneExecuteResults(executionContext, ex);
         }
@@ -212,14 +213,15 @@ public final class ProxySQLExecutor {
     private List<ExecuteResult> useDriverToExecute(final ExecutionContext 
executionContext, final Collection<ShardingSphereRule> rules,
                                                    final int 
maxConnectionsSizePerQuery, final boolean isReturnGeneratedKeys, final boolean 
isExceptionThrown) throws SQLException {
         JDBCBackendStatement statementManager = (JDBCBackendStatement) 
databaseConnectionManager.getConnectionSession().getStatementManager();
+        String databaseName = 
databaseConnectionManager.getConnectionSession().getDatabaseName();
         DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> 
prepareEngine = new DriverExecutionPrepareEngine<>(
                 type, maxConnectionsSizePerQuery, databaseConnectionManager, 
statementManager, new StatementOption(isReturnGeneratedKeys), rules,
-                
ProxyContext.getInstance().getContextManager().getDatabase(databaseConnectionManager.getConnectionSession().getDatabaseName()).getResourceMetaData().getStorageUnits());
+                
ProxyContext.getInstance().getContextManager().getDatabase(databaseName).getResourceMetaData().getStorageUnits());
         ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext;
         try {
-            executionGroupContext = 
prepareEngine.prepare(executionContext.getRouteContext(), 
executionContext.getExecutionUnits(),
+            executionGroupContext = prepareEngine.prepare(databaseName, 
executionContext.getRouteContext(), executionContext.getExecutionUnits(),
                     new 
ExecutionGroupReportContext(databaseConnectionManager.getConnectionSession().getProcessId(),
-                            
databaseConnectionManager.getConnectionSession().getDatabaseName(), 
databaseConnectionManager.getConnectionSession().getConnectionContext().getGrantee()));
+                            databaseName, 
databaseConnectionManager.getConnectionSession().getConnectionContext().getGrantee()));
         } catch (final SQLException ex) {
             return getSaneExecuteResults(executionContext, ex);
         }
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
index 18d70ce4b95..e071a08c583 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/ProxyDatabaseConnectionManagerTest.java
@@ -141,7 +141,7 @@ class ProxyDatabaseConnectionManagerTest {
     void assertGetConnectionCacheIsEmpty() throws SQLException {
         connectionSession.getTransactionStatus().setInTransaction(true);
         when(backendDataSource.getConnections(anyString(), anyString(), eq(2), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(2));
-        List<Connection> actualConnections = 
databaseConnectionManager.getConnections("ds1", 0, 2, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actualConnections = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds1", 0, 
2, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actualConnections.size(), is(2));
         assertThat(databaseConnectionManager.getConnectionSize(), is(2));
         assertTrue(connectionSession.getTransactionStatus().isInTransaction());
@@ -151,7 +151,7 @@ class ProxyDatabaseConnectionManagerTest {
     void assertGetConnectionSizeLessThanCache() throws SQLException {
         connectionSession.getTransactionStatus().setInTransaction(true);
         MockConnectionUtils.setCachedConnections(databaseConnectionManager, 
"ds1", 10);
-        List<Connection> actualConnections = 
databaseConnectionManager.getConnections("ds1", 0, 2, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actualConnections = 
databaseConnectionManager.getConnections(connectionSession.getDatabaseName(), 
"ds1", 0, 2, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actualConnections.size(), is(2));
         assertThat(databaseConnectionManager.getConnectionSize(), is(10));
         assertTrue(connectionSession.getTransactionStatus().isInTransaction());
@@ -162,7 +162,7 @@ class ProxyDatabaseConnectionManagerTest {
         connectionSession.getTransactionStatus().setInTransaction(true);
         MockConnectionUtils.setCachedConnections(databaseConnectionManager, 
"ds1", 10);
         when(backendDataSource.getConnections(anyString(), anyString(), eq(2), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(2));
-        List<Connection> actualConnections = 
databaseConnectionManager.getConnections("ds1", 0, 12, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actualConnections = 
databaseConnectionManager.getConnections(connectionSession.getDatabaseName(), 
"ds1", 0, 12, ConnectionMode.MEMORY_STRICTLY);
         assertThat(actualConnections.size(), is(12));
         assertThat(databaseConnectionManager.getConnectionSize(), is(12));
         assertTrue(connectionSession.getTransactionStatus().isInTransaction());
@@ -173,7 +173,7 @@ class ProxyDatabaseConnectionManagerTest {
         connectionSession.getTransactionStatus().setInTransaction(true);
         when(backendDataSource.getConnections(anyString(), anyString(), eq(2), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(2));
         setConnectionPostProcessors();
-        List<Connection> actualConnections = 
databaseConnectionManager.getConnections("ds1", 0, 2, 
ConnectionMode.MEMORY_STRICTLY);
+        List<Connection> actualConnections = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds1", 0, 
2, ConnectionMode.MEMORY_STRICTLY);
         
verify(databaseConnectionManager.getConnectionPostProcessors().iterator().next(),
 times(2)).process(any());
         assertThat(actualConnections.size(), is(2));
         assertTrue(connectionSession.getTransactionStatus().isInTransaction());
@@ -250,7 +250,7 @@ class ProxyDatabaseConnectionManagerTest {
         Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
         
when(connection.getMetaData().getDatabaseProductName()).thenReturn("PostgreSQL");
         when(proxyContext.getBackendDataSource().getConnections(anyString(), 
anyString(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
-        List<Connection> actualConnections = 
databaseConnectionManager.getConnections("", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
+        List<Connection> actualConnections = 
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
         Connection actualConnection = actualConnections.get(0);
         verify(actualConnection.createStatement()).execute("SET key=value");
     }
@@ -265,7 +265,7 @@ class ProxyDatabaseConnectionManagerTest {
             
when(connection.getMetaData().getDatabaseProductName()).thenReturn("PostgreSQL");
             when(connection.createStatement().execute("SET 
key=value")).thenThrow(expectedException);
             
when(ProxyContext.getInstance().getBackendDataSource().getConnections(anyString(),
 anyString(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
-            databaseConnectionManager.getConnections("", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
+            
databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "", 0, 1, 
ConnectionMode.CONNECTION_STRICTLY);
         } catch (final SQLException ex) {
             assertThat(ex, is(expectedException));
             verify(connection).close();
@@ -277,7 +277,7 @@ class ProxyDatabaseConnectionManagerTest {
         connectionSession.getTransactionStatus().setInTransaction(false);
         List<Connection> connections = 
MockConnectionUtils.mockNewConnections(1);
         when(backendDataSource.getConnections(anyString(), anyString(), eq(1), 
any())).thenReturn(connections);
-        List<Connection> fetchedConnections = 
databaseConnectionManager.getConnections("ds1", 0, 1, null);
+        List<Connection> fetchedConnections = 
databaseConnectionManager.getConnections(connectionSession.getDatabaseName(), 
"ds1", 0, 1, null);
         assertThat(fetchedConnections.size(), is(1));
         assertTrue(fetchedConnections.contains(connections.get(0)));
         assertConnectionsCached(connectionSession.getDatabaseName() + ".ds1", 
connections);
@@ -295,14 +295,14 @@ class ProxyDatabaseConnectionManagerTest {
     @Test
     void assertGetConnectionWithConnectionOffset() throws SQLException {
         when(backendDataSource.getConnections(anyString(), anyString(), eq(1), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(1));
-        assertThat(databaseConnectionManager.getConnections("ds1", 0, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                is(databaseConnectionManager.getConnections("ds1", 0, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds1", 0, 1, ConnectionMode.MEMORY_STRICTLY),
+                
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds1", 
0, 1, ConnectionMode.MEMORY_STRICTLY)));
         when(backendDataSource.getConnections(anyString(), anyString(), eq(1), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(1));
-        assertThat(databaseConnectionManager.getConnections("ds1", 1, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                is(databaseConnectionManager.getConnections("ds1", 1, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds1", 1, 1, ConnectionMode.MEMORY_STRICTLY),
+                
is(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds1", 
1, 1, ConnectionMode.MEMORY_STRICTLY)));
         when(backendDataSource.getConnections(anyString(), anyString(), eq(1), 
any())).thenReturn(MockConnectionUtils.mockNewConnections(1));
-        assertThat(databaseConnectionManager.getConnections("ds1", 0, 1, 
ConnectionMode.MEMORY_STRICTLY),
-                not(databaseConnectionManager.getConnections("ds1", 1, 1, 
ConnectionMode.MEMORY_STRICTLY)));
+        
assertThat(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, 
"ds1", 0, 1, ConnectionMode.MEMORY_STRICTLY),
+                
not(databaseConnectionManager.getConnections(DefaultDatabase.LOGIC_NAME, "ds1", 
1, 1, ConnectionMode.MEMORY_STRICTLY)));
     }
     
     @Test
diff --git 
a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
 
b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
index 51218969215..191117f26e8 100644
--- 
a/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
+++ 
b/proxy/frontend/type/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandler.java
@@ -136,7 +136,7 @@ public final class MySQLMultiStatementsHandler implements 
ProxyBackendHandler {
         Collection<ExecutionContext> executionContexts = 
createExecutionContexts();
         Map<String, List<ExecutionUnit>> dataSourcesToExecutionUnits = 
buildDataSourcesToExecutionUnits(executionContexts);
         ExecutionGroupContext<JDBCExecutionUnit> executionGroupContext =
-                
prepareEngine.prepare(executionContexts.iterator().next().getRouteContext(), 
samplingExecutionUnit(dataSourcesToExecutionUnits),
+                prepareEngine.prepare(connectionSession.getDatabaseName(), 
executionContexts.iterator().next().getRouteContext(), 
samplingExecutionUnit(dataSourcesToExecutionUnits),
                         new 
ExecutionGroupReportContext(connectionSession.getProcessId(), 
connectionSession.getDatabaseName(), 
connectionSession.getConnectionContext().getGrantee()));
         for (ExecutionGroup<JDBCExecutionUnit> each : 
executionGroupContext.getInputGroups()) {
             for (JDBCExecutionUnit unit : each.getInputs()) {
diff --git 
a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
 
b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
index 109c794622d..78370a4a8c0 100644
--- 
a/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
+++ 
b/proxy/frontend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLMultiStatementsHandlerTest.java
@@ -109,7 +109,7 @@ class MySQLMultiStatementsHandlerTest {
         when(statement.getConnection()).thenReturn(connection);
         when(statement.executeBatch()).thenReturn(new int[]{1, 1, 1});
         ProxyDatabaseConnectionManager databaseConnectionManager = 
mock(ProxyDatabaseConnectionManager.class);
-        when(databaseConnectionManager.getConnections(nullable(String.class), 
anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
+        when(databaseConnectionManager.getConnections(any(), 
nullable(String.class), anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
         
when(result.getDatabaseConnectionManager()).thenReturn(databaseConnectionManager);
         JDBCBackendStatement backendStatement = 
mock(JDBCBackendStatement.class);
         when(backendStatement.createStorageResource(eq(connection), 
any(ConnectionMode.class), any(StatementOption.class), 
nullable(DatabaseType.class))).thenReturn(statement);
diff --git 
a/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
 
b/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
index 89b58a05591..4eed580b50e 100644
--- 
a/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
+++ 
b/proxy/frontend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/frontend/opengauss/command/query/extended/bind/OpenGaussComBatchBindExecutorTest.java
@@ -106,7 +106,7 @@ class OpenGaussComBatchBindExecutorTest {
         when(result.getDatabaseName()).thenReturn("foo_db");
         ProxyDatabaseConnectionManager databaseConnectionManager = 
mock(ProxyDatabaseConnectionManager.class);
         Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
-        when(databaseConnectionManager.getConnections(nullable(String.class), 
anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
+        when(databaseConnectionManager.getConnections(any(), 
nullable(String.class), anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
         PreparedStatement preparedStatement = mock(PreparedStatement.class);
         JDBCBackendStatement backendStatement = 
mock(JDBCBackendStatement.class);
         when(backendStatement.createStorageResource(any(ExecutionUnit.class), 
any(Connection.class), any(ConnectionMode.class), any(StatementOption.class), 
nullable(DatabaseType.class)))
diff --git 
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
 
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
index 2cd40359979..3ba227fc606 100644
--- 
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
+++ 
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutor.java
@@ -152,7 +152,7 @@ public final class PostgreSQLBatchedStatementsExecutor {
                 
metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY),
                 connectionSession.getDatabaseConnectionManager(), 
(JDBCBackendStatement) connectionSession.getStatementManager(),
                 new StatementOption(false), rules, 
metaDataContexts.getMetaData().getDatabase(connectionSession.getDatabaseName()).getResourceMetaData().getStorageUnits());
-        executionGroupContext = 
prepareEngine.prepare(anyExecutionContext.getRouteContext(), 
executionUnitParams.keySet(),
+        executionGroupContext = 
prepareEngine.prepare(connectionSession.getDatabaseName(), 
anyExecutionContext.getRouteContext(), executionUnitParams.keySet(),
                 new 
ExecutionGroupReportContext(connectionSession.getProcessId(), 
connectionSession.getDatabaseName(), 
connectionSession.getConnectionContext().getGrantee()));
         for (ExecutionGroup<JDBCExecutionUnit> eachGroup : 
executionGroupContext.getInputGroups()) {
             for (JDBCExecutionUnit each : eachGroup.getInputs()) {
diff --git 
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
 
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
index eb06c606f57..f25e9b314b4 100644
--- 
a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
+++ 
b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutor.java
@@ -246,7 +246,7 @@ public final class PostgreSQLComDescribeExecutor implements 
CommandExecutor {
                 queryContext, database, 
metaDataContexts.getMetaData().getGlobalRuleMetaData(), 
metaDataContexts.getMetaData().getProps(), 
connectionSession.getConnectionContext());
         ExecutionUnit executionUnitSample = 
executionContext.getExecutionUnits().iterator().next();
         ProxyDatabaseConnectionManager databaseConnectionManager = 
connectionSession.getDatabaseConnectionManager();
-        Connection connection = 
databaseConnectionManager.getConnections(executionUnitSample.getDataSourceName(),
 0, 1, ConnectionMode.CONNECTION_STRICTLY).iterator().next();
+        Connection connection = 
databaseConnectionManager.getConnections(databaseName, 
executionUnitSample.getDataSourceName(), 0, 1, 
ConnectionMode.CONNECTION_STRICTLY).iterator().next();
         try (PreparedStatement actualPreparedStatement = 
connection.prepareStatement(executionUnitSample.getSqlUnit().getSql())) {
             populateParameterTypes(logicPreparedStatement, 
actualPreparedStatement);
             populateColumnTypes(logicPreparedStatement, 
actualPreparedStatement);
diff --git 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
index f3b286714f3..4650c2aec5d 100644
--- 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
+++ 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLAggregatedBatchedStatementsCommandExecutorTest.java
@@ -122,7 +122,7 @@ class 
PostgreSQLAggregatedBatchedStatementsCommandExecutorTest {
         ProxyDatabaseConnectionManager databaseConnectionManager = 
mock(ProxyDatabaseConnectionManager.class);
         Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
         
when(connection.getMetaData().getURL()).thenReturn("jdbc:postgresql://127.0.0.1/db");
-        when(databaseConnectionManager.getConnections(nullable(String.class), 
anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
+        when(databaseConnectionManager.getConnections(any(), 
nullable(String.class), anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
         PreparedStatement preparedStatement = mock(PreparedStatement.class);
         when(preparedStatement.getConnection()).thenReturn(connection);
         JDBCBackendStatement backendStatement = 
mock(JDBCBackendStatement.class);
diff --git 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
index 512ef647cea..cb973a4f27e 100644
--- 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
+++ 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PostgreSQLBatchedStatementsExecutorTest.java
@@ -91,7 +91,7 @@ class PostgreSQLBatchedStatementsExecutorTest {
     void assertExecuteBatch() throws SQLException {
         Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
         
when(connection.getMetaData().getURL()).thenReturn("jdbc:postgresql://127.0.0.1/db");
-        when(databaseConnectionManager.getConnections(nullable(String.class), 
anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
+        when(databaseConnectionManager.getConnections(any(), 
nullable(String.class), anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
         PreparedStatement preparedStatement = mock(PreparedStatement.class);
         when(preparedStatement.getConnection()).thenReturn(connection);
         when(preparedStatement.executeBatch()).thenReturn(new int[]{1, 1, 1});
diff --git 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
index 26a61b5d24e..fab5310bc08 100644
--- 
a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
+++ 
b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/describe/PostgreSQLComDescribeExecutorTest.java
@@ -408,7 +408,7 @@ class PostgreSQLComDescribeExecutorTest {
         
when(connection.prepareStatement(sql).getParameterMetaData()).thenReturn(parameterMetaData);
         ResultSetMetaData resultSetMetaData = prepareResultSetMetaData();
         
when(connection.prepareStatement(sql).getMetaData()).thenReturn(resultSetMetaData);
-        when(databaseConnectionManager.getConnections(nullable(String.class), 
anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
+        when(databaseConnectionManager.getConnections(any(), 
nullable(String.class), anyInt(), anyInt(), 
any(ConnectionMode.class))).thenReturn(Collections.singletonList(connection));
         
when(connectionSession.getDatabaseConnectionManager()).thenReturn(databaseConnectionManager);
     }
     

Reply via email to