This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 f38dd36a662 Use SPI on DriverExecutorFacade (#32669)
f38dd36a662 is described below
commit f38dd36a662ff34daa274f131be4981c584f258c
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Aug 25 14:11:36 2024 +0800
Use SPI on DriverExecutorFacade (#32669)
* Use SPI on DriverExecutorFacade
* Use SPI on DriverExecutorFacade
* Use SPI on DriverExecutorFacade
---
.../engine/facade/DriverExecutorFacade.java | 100 +++++++++++++++++++++
.../engine/facade/DriverExecutorFacadeFactory.java | 42 +++++++++
.../standard/StandardDriverExecutorFacade.java} | 64 +++----------
.../StandardDriverExecutorFacadeFactory.java | 46 ++++++++++
.../core/connection/ShardingSphereConnection.java | 23 ++---
.../statement/ShardingSpherePreparedStatement.java | 31 ++++---
.../core/statement/ShardingSphereStatement.java | 16 ++--
.../driver/state/ok/OKDriverState.java | 2 +-
...cutor.engine.facade.DriverExecutorFacadeFactory | 18 ++++
.../driver/jdbc/adapter/ConnectionAdapterTest.java | 2 +-
.../jdbc/adapter/PreparedStatementAdapterTest.java | 2 +-
.../driver/jdbc/adapter/StatementAdapterTest.java | 4 +-
.../connection/ShardingSphereConnectionTest.java | 24 ++---
.../UnsupportedOperationConnectionTest.java | 2 +-
.../UnsupportedOperationPreparedStatementTest.java | 2 +-
.../UnsupportedOperationStatementTest.java | 2 +-
16 files changed, 279 insertions(+), 101 deletions(-)
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
new file mode 100644
index 00000000000..1ace4cab0ec
--- /dev/null
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacade.java
@@ -0,0 +1,100 @@
+/*
+ * 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.driver.executor.engine.facade;
+
+import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
+import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteCallback;
+import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
+import
org.apache.shardingsphere.driver.executor.callback.replay.StatementReplayCallback;
+import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
+import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
+import org.apache.shardingsphere.infra.session.query.QueryContext;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Driver executor facade.
+ */
+public interface DriverExecutorFacade extends AutoCloseable {
+
+ /**
+ * Execute query.
+ *
+ * @param database database
+ * @param queryContext query context
+ * @param statement statement
+ * @param columnLabelAndIndexMap column label and index map
+ * @param addCallback statement add callback
+ * @param replayCallback statement replay callback
+ * @return result set
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings("rawtypes")
+ ResultSet executeQuery(ShardingSphereDatabase database, QueryContext
queryContext,
+ Statement statement, Map<String, Integer>
columnLabelAndIndexMap, StatementAddCallback addCallback,
StatementReplayCallback replayCallback) throws SQLException;
+
+ /**
+ * Execute update.
+ *
+ * @param database database
+ * @param queryContext query context
+ * @param executeUpdateCallback statement execute update callback
+ * @param replayCallback statement replay callback
+ * @param addCallback statement add callback
+ * @return updated row count
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings("rawtypes")
+ int executeUpdate(ShardingSphereDatabase database,
+ QueryContext queryContext,
StatementExecuteUpdateCallback executeUpdateCallback, StatementAddCallback
addCallback, StatementReplayCallback replayCallback) throws SQLException;
+
+ /**
+ * Execute.
+ *
+ * @param database database
+ * @param queryContext query context
+ * @param executeCallback statement execute callback
+ * @param addCallback statement add callback
+ * @param replayCallback statement replay callback
+ * @return execute result
+ * @throws SQLException SQL exception
+ */
+ @SuppressWarnings("rawtypes")
+ boolean execute(ShardingSphereDatabase database,
+ QueryContext queryContext, StatementExecuteCallback
executeCallback, StatementAddCallback addCallback, StatementReplayCallback
replayCallback) throws SQLException;
+
+ /**
+ * Get result set.
+ *
+ * @param database database
+ * @param sqlStatementContext SQL statement context
+ * @param statement statement
+ * @param statements statements
+ * @return result set
+ * @throws SQLException SQL exception
+ */
+ Optional<ResultSet> getResultSet(ShardingSphereDatabase database,
SQLStatementContext sqlStatementContext, Statement statement, List<? extends
Statement> statements) throws SQLException;
+
+ @Override
+ void close() throws SQLException;
+}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
new file mode 100644
index 00000000000..7c15bfd1ee0
--- /dev/null
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/DriverExecutorFacadeFactory.java
@@ -0,0 +1,42 @@
+/*
+ * 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.driver.executor.engine.facade;
+
+import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
+import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
+import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPI;
+
+/**
+ * Driver executor facade factory.
+ */
+@SingletonSPI
+public interface DriverExecutorFacadeFactory extends TypedSPI {
+
+ /**
+ * Create new instance of driver executor facade.
+ *
+ * @param connection connection
+ * @param statementOption statement option
+ * @param statementManager statement manager
+ * @param jdbcDriverType JDBC driver type
+ * @return created instance
+ */
+ DriverExecutorFacade newInstance(ShardingSphereConnection connection,
StatementOption statementOption, StatementManager statementManager, String
jdbcDriverType);
+}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/DriverExecutorFacade.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
similarity index 79%
rename from
jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/DriverExecutorFacade.java
rename to
jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
index 57be7c4bac7..c361dd670a7 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/DriverExecutorFacade.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacade.java
@@ -15,12 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.driver.executor.engine;
+package org.apache.shardingsphere.driver.executor.engine.facade.standard;
import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteCallback;
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
import
org.apache.shardingsphere.driver.executor.callback.replay.StatementReplayCallback;
+import org.apache.shardingsphere.driver.executor.engine.DriverExecuteExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteQueryExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.DriverExecuteUpdateExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
@@ -46,9 +50,9 @@ import java.util.Map;
import java.util.Optional;
/**
- * Driver executor facade.
+ * Standard driver executor facade.
*/
-public final class DriverExecutorFacade implements AutoCloseable {
+public final class StandardDriverExecutorFacade implements
DriverExecutorFacade {
private final ShardingSphereConnection connection;
@@ -66,7 +70,7 @@ public final class DriverExecutorFacade implements
AutoCloseable {
private final DriverExecuteExecutor executeExecutor;
- public DriverExecutorFacade(final ShardingSphereConnection connection,
final StatementOption statementOption, final StatementManager statementManager,
final String jdbcDriverType) {
+ public StandardDriverExecutorFacade(final ShardingSphereConnection
connection, final StatementOption statementOption, final StatementManager
statementManager, final String jdbcDriverType) {
this.connection = connection;
this.statementOption = statementOption;
this.statementManager = statementManager;
@@ -82,18 +86,7 @@ public final class DriverExecutorFacade implements
AutoCloseable {
executeExecutor = new DriverExecuteExecutor(connection, metaData,
jdbcExecutor, rawExecutor, sqlFederationEngine);
}
- /**
- * Execute query.
- *
- * @param database database
- * @param queryContext query context
- * @param statement statement
- * @param columnLabelAndIndexMap column label and index map
- * @param addCallback statement add callback
- * @param replayCallback statement replay callback
- * @return result set
- * @throws SQLException SQL exception
- */
+ @Override
@SuppressWarnings("rawtypes")
public ResultSet executeQuery(final ShardingSphereDatabase database, final
QueryContext queryContext, final Statement statement, final Map<String,
Integer> columnLabelAndIndexMap,
final StatementAddCallback addCallback,
final StatementReplayCallback replayCallback) throws SQLException {
@@ -101,17 +94,7 @@ public final class DriverExecutorFacade implements
AutoCloseable {
return queryExecutor.executeQuery(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType), statement,
columnLabelAndIndexMap, addCallback, replayCallback);
}
- /**
- * Execute update.
- *
- * @param database database
- * @param queryContext query context
- * @param executeUpdateCallback statement execute update callback
- * @param replayCallback statement replay callback
- * @param addCallback statement add callback
- * @return updated row count
- * @throws SQLException SQL exception
- */
+ @Override
@SuppressWarnings("rawtypes")
public int executeUpdate(final ShardingSphereDatabase database, final
QueryContext queryContext,
final StatementExecuteUpdateCallback
executeUpdateCallback, final StatementAddCallback addCallback, final
StatementReplayCallback replayCallback) throws SQLException {
@@ -119,17 +102,7 @@ public final class DriverExecutorFacade implements
AutoCloseable {
return updateExecutor.executeUpdate(database, queryContext,
createDriverExecutionPrepareEngine(database, jdbcDriverType),
executeUpdateCallback, addCallback, replayCallback);
}
- /**
- * Execute.
- *
- * @param database database
- * @param queryContext query context
- * @param executeCallback statement execute callback
- * @param addCallback statement add callback
- * @param replayCallback statement replay callback
- * @return execute result
- * @throws SQLException SQL exception
- */
+ @Override
@SuppressWarnings("rawtypes")
public boolean execute(final ShardingSphereDatabase database, final
QueryContext queryContext,
final StatementExecuteCallback executeCallback,
final StatementAddCallback addCallback, final StatementReplayCallback
replayCallback) throws SQLException {
@@ -143,18 +116,9 @@ public final class DriverExecutorFacade implements
AutoCloseable {
database.getRuleMetaData().getRules(),
database.getResourceMetaData().getStorageUnits());
}
- /**
- * Get result set.
- *
- * @param database database
- * @param sqlStatementContext SQL statement context
- * @param statement statement
- * @param statements statements
- * @return result set
- * @throws SQLException SQL exception
- */
- public Optional<ResultSet> getResultSet(final ShardingSphereDatabase
database, final SQLStatementContext sqlStatementContext,
- final Statement statement, final
List<? extends Statement> statements) throws SQLException {
+ @Override
+ public Optional<ResultSet> getResultSet(final ShardingSphereDatabase
database,
+ final SQLStatementContext
sqlStatementContext, final Statement statement, final List<? extends Statement>
statements) throws SQLException {
return executeExecutor.getResultSet(database, sqlStatementContext,
statement, statements);
}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
new file mode 100644
index 00000000000..f3799660900
--- /dev/null
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/engine/facade/standard/StandardDriverExecutorFacadeFactory.java
@@ -0,0 +1,46 @@
+/*
+ * 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.driver.executor.engine.facade.standard;
+
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
+import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
+import org.apache.shardingsphere.driver.jdbc.core.statement.StatementManager;
+import
org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
+
+/**
+ * Standard driver executor facade factory.
+ */
+public final class StandardDriverExecutorFacadeFactory implements
DriverExecutorFacadeFactory {
+
+ @Override
+ public DriverExecutorFacade newInstance(final ShardingSphereConnection
connection,
+ final StatementOption
statementOption, final StatementManager statementManager, final String
jdbcDriverType) {
+ return new StandardDriverExecutorFacade(connection, statementOption,
statementManager, jdbcDriverType);
+ }
+
+ @Override
+ public Object getType() {
+ return "Standard";
+ }
+
+ @Override
+ public boolean isDefault() {
+ return true;
+ }
+}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index 28c2251c901..3a6327f06c6 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -68,6 +68,8 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
@Getter
private final String processId;
+ private final String executorType;
+
private boolean autoCommit = true;
private int transactionIsolation = TRANSACTION_READ_UNCOMMITTED;
@@ -76,11 +78,12 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
private volatile boolean closed;
- public ShardingSphereConnection(final String currentDatabaseName, final
ContextManager contextManager) {
+ public ShardingSphereConnection(final String currentDatabaseName, final
ContextManager contextManager, final String executorType) {
this.currentDatabaseName = currentDatabaseName;
this.contextManager = contextManager;
databaseConnectionManager = new
DriverDatabaseConnectionManager(currentDatabaseName, contextManager);
processId = processEngine.connect(currentDatabaseName);
+ this.executorType = executorType;
}
/**
@@ -102,47 +105,47 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
@Override
public PreparedStatement prepareStatement(final String sql) throws
SQLException {
- return new ShardingSpherePreparedStatement(this, sql);
+ return new ShardingSpherePreparedStatement(this, sql, executorType);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
resultSetType, final int resultSetConcurrency) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency);
+ return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, executorType);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
resultSetType, final int resultSetConcurrency, final int resultSetHoldability)
throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, resultSetHoldability);
+ return new ShardingSpherePreparedStatement(this, sql, resultSetType,
resultSetConcurrency, resultSetHoldability, executorType);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int
autoGeneratedKeys) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql,
autoGeneratedKeys);
+ return new ShardingSpherePreparedStatement(this, sql,
autoGeneratedKeys, executorType);
}
@Override
public PreparedStatement prepareStatement(final String sql, final int[]
columnIndexes) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql,
Statement.RETURN_GENERATED_KEYS);
+ return new ShardingSpherePreparedStatement(this, sql,
Statement.RETURN_GENERATED_KEYS, executorType);
}
@Override
public PreparedStatement prepareStatement(final String sql, final String[]
columnNames) throws SQLException {
- return new ShardingSpherePreparedStatement(this, sql, columnNames);
+ return new ShardingSpherePreparedStatement(this, sql, columnNames,
executorType);
}
@Override
public Statement createStatement() {
- return new ShardingSphereStatement(this);
+ return new ShardingSphereStatement(this, executorType);
}
@Override
public Statement createStatement(final int resultSetType, final int
resultSetConcurrency) {
- return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency);
+ return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, executorType);
}
@Override
public Statement createStatement(final int resultSetType, final int
resultSetConcurrency, final int resultSetHoldability) {
- return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, resultSetHoldability);
+ return new ShardingSphereStatement(this, resultSetType,
resultSetConcurrency, resultSetHoldability, executorType);
}
@Override
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
index 0b585e01c22..3304a614ea4 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java
@@ -20,8 +20,9 @@ package org.apache.shardingsphere.driver.jdbc.core.statement;
import lombok.AccessLevel;
import lombok.Getter;
import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
-import org.apache.shardingsphere.driver.executor.engine.DriverExecutorFacade;
import
org.apache.shardingsphere.driver.executor.engine.batch.preparedstatement.DriverExecuteBatchExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
import
org.apache.shardingsphere.driver.jdbc.adapter.AbstractPreparedStatementAdapter;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
@@ -49,6 +50,7 @@ import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
import
org.apache.shardingsphere.infra.rule.attribute.resoure.StorageConnectorReusableRuleAttribute;
import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.transaction.util.AutoCommitUtils;
@@ -111,29 +113,30 @@ public final class ShardingSpherePreparedStatement
extends AbstractPreparedState
private ResultSet currentBatchGeneratedKeysResultSet;
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String executorType) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null,
executorType);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency) throws SQLException {
- this(connection, sql, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
+ final String executorType) throws
SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, false, null, executorType);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int autoGeneratedKeys) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT,
RETURN_GENERATED_KEYS == autoGeneratedKeys, null);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int autoGeneratedKeys, final String
executorType) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT,
RETURN_GENERATED_KEYS == autoGeneratedKeys, null, executorType);
}
- public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String[] columns) throws SQLException {
- this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, true, columns);
+ public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final String[] columns, final String
executorType) throws SQLException {
+ this(connection, sql, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, true, columns,
executorType);
}
public ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
- final int resultSetHoldability)
throws SQLException {
- this(connection, sql, resultSetType, resultSetConcurrency,
resultSetHoldability, false, null);
+ final int resultSetHoldability,
final String executorType) throws SQLException {
+ this(connection, sql, resultSetType, resultSetConcurrency,
resultSetHoldability, false, null, executorType);
}
- private ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType,
- final int resultSetConcurrency,
final int resultSetHoldability, final boolean returnGeneratedKeys, final
String[] columns) throws SQLException {
+ private ShardingSpherePreparedStatement(final ShardingSphereConnection
connection, final String sql, final int resultSetType, final int
resultSetConcurrency,
+ final int resultSetHoldability,
final boolean returnGeneratedKeys, final String[] columns, final String
executorType) throws SQLException {
ShardingSpherePreconditions.checkNotEmpty(sql, () -> new
EmptySQLException().toSQLException());
this.connection = connection;
metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
@@ -150,7 +153,7 @@ public final class ShardingSpherePreparedStatement extends
AbstractPreparedState
statementManager = new StatementManager();
connection.getStatementManagers().add(statementManager);
parameterMetaData = new ShardingSphereParameterMetaData(sqlStatement);
- driverExecutorFacade = new DriverExecutorFacade(connection,
statementOption, statementManager, JDBCDriverType.PREPARED_STATEMENT);
+ driverExecutorFacade =
TypedSPILoader.getService(DriverExecutorFacadeFactory.class,
executorType).newInstance(connection, statementOption, statementManager,
JDBCDriverType.PREPARED_STATEMENT);
executeBatchExecutor = new DriverExecuteBatchExecutor(connection,
metaData, statementOption, statementManager, usedDatabase);
statementsCacheable = isStatementsCacheable();
}
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index dbb8885a40b..cb6b10cf525 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -22,8 +22,9 @@ import lombok.Getter;
import
org.apache.shardingsphere.driver.executor.callback.add.StatementAddCallback;
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteCallback;
import
org.apache.shardingsphere.driver.executor.callback.execute.StatementExecuteUpdateCallback;
-import org.apache.shardingsphere.driver.executor.engine.DriverExecutorFacade;
import
org.apache.shardingsphere.driver.executor.engine.batch.statement.BatchStatementExecutor;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacade;
+import
org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory;
import org.apache.shardingsphere.driver.jdbc.adapter.AbstractStatementAdapter;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
@@ -46,6 +47,7 @@ import
org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
import org.apache.shardingsphere.infra.session.query.QueryContext;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.parser.rule.SQLParserRule;
import
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.transaction.util.AutoCommitUtils;
@@ -89,21 +91,21 @@ public final class ShardingSphereStatement extends
AbstractStatementAdapter {
private ResultSet currentResultSet;
- public ShardingSphereStatement(final ShardingSphereConnection connection) {
- this(connection, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ public ShardingSphereStatement(final ShardingSphereConnection connection,
final String executorType) {
+ this(connection, ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, executorType);
}
- public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency) {
- this(connection, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final String
executorType) {
+ this(connection, resultSetType, resultSetConcurrency,
ResultSet.HOLD_CURSORS_OVER_COMMIT, executorType);
}
- public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final int
resultSetHoldability) {
+ public ShardingSphereStatement(final ShardingSphereConnection connection,
final int resultSetType, final int resultSetConcurrency, final int
resultSetHoldability, final String executorType) {
this.connection = connection;
metaData =
connection.getContextManager().getMetaDataContexts().getMetaData();
statementOption = new StatementOption(resultSetType,
resultSetConcurrency, resultSetHoldability);
statementManager = new StatementManager();
connection.getStatementManagers().add(statementManager);
- driverExecutorFacade = new DriverExecutorFacade(connection,
statementOption, statementManager, JDBCDriverType.STATEMENT);
+ driverExecutorFacade =
TypedSPILoader.getService(DriverExecutorFacadeFactory.class,
executorType).newInstance(connection, statementOption, statementManager,
JDBCDriverType.STATEMENT);
batchStatementExecutor = new BatchStatementExecutor(this);
statements = new LinkedList<>();
usedDatabaseName = connection.getCurrentDatabaseName();
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
index 75e3a07a70a..78f43c6abe3 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/state/ok/OKDriverState.java
@@ -30,6 +30,6 @@ public final class OKDriverState implements DriverState {
@Override
public Connection getConnection(final String databaseName, final
ContextManager contextManager) {
- return new ShardingSphereConnection(databaseName, contextManager);
+ return new ShardingSphereConnection(databaseName, contextManager,
null);
}
}
diff --git
a/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
b/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
new file mode 100644
index 00000000000..0dadb7fcb12
--- /dev/null
+++
b/jdbc/src/main/resources/META-INF/services/org.apache.shardingsphere.driver.executor.engine.facade.DriverExecutorFacadeFactory
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.driver.executor.engine.facade.standard.StandardDriverExecutorFacadeFactory
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
index 2b80d4b212b..641ea83b66d 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/ConnectionAdapterTest.java
@@ -97,6 +97,6 @@ class ConnectionAdapterTest {
private Connection createConnectionAdaptor() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
RuleMetaData(Collections.singleton(mock(TransactionRule.class,
RETURNS_DEEP_STUBS))));
- return new ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
contextManager);
+ return new ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
contextManager, null);
}
}
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
index 37723f0235b..15c3a675e23 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/PreparedStatementAdapterTest.java
@@ -72,7 +72,7 @@ class PreparedStatementAdapterTest {
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(
connection.getCurrentDatabaseName()).getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
- shardingSpherePreparedStatement = new
ShardingSpherePreparedStatement(connection, "SELECT 1");
+ shardingSpherePreparedStatement = new
ShardingSpherePreparedStatement(connection, "SELECT 1", null);
}
@Test
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
index b4afabec12f..17a8e2de8e4 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/StatementAdapterTest.java
@@ -242,7 +242,7 @@ class StatementAdapterTest {
when(connection.getCurrentDatabaseName()).thenReturn("db");
DatabaseType databaseType =
TypedSPILoader.getService(DatabaseType.class, "FIXTURE");
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase("db").getProtocolType()).thenReturn(databaseType);
- ShardingSphereStatement result = new
ShardingSphereStatement(connection);
+ ShardingSphereStatement result = new
ShardingSphereStatement(connection, null);
result.getRoutedStatements().addAll(Arrays.asList(statements));
return result;
}
@@ -260,7 +260,7 @@ class StatementAdapterTest {
new SQLFederationRule(new
DefaultSQLFederationRuleConfigurationBuilder().build(), Collections.emptyMap()),
new SQLParserRule(new
DefaultSQLParserRuleConfigurationBuilder().build()))));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
- ShardingSphereStatement result = new
ShardingSphereStatement(connection);
+ ShardingSphereStatement result = new
ShardingSphereStatement(connection, null);
result.getRoutedStatements().addAll(Arrays.asList(statements));
setExecutionContext(result);
return result;
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 6adf01dbdbf..7a7aa07e2d3 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
@@ -53,7 +53,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetAutoCommitWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection))) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection), null)) {
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(true);
assertTrue(connection.getAutoCommit());
@@ -66,7 +66,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(true)).thenReturn(DistributedTransactionOperationType.COMMIT);
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
DriverDatabaseConnectionManager connectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(true);
assertTrue(connection.getAutoCommit());
@@ -77,7 +77,7 @@ class ShardingSphereConnectionTest {
@Test
void assertCommitWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection))) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection), null)) {
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -94,7 +94,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(false)).thenReturn(DistributedTransactionOperationType.BEGIN);
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
DriverDatabaseConnectionManager databaseConnectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -107,7 +107,7 @@ class ShardingSphereConnectionTest {
@Test
void assertRollbackWithLocalTransaction() throws SQLException {
Connection physicalConnection = mock(Connection.class);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection))) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME,
mockContextManager(physicalConnection), null)) {
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -121,7 +121,7 @@ class ShardingSphereConnectionTest {
ConnectionTransaction connectionTransaction =
mock(ConnectionTransaction.class);
when(connectionTransaction.getDistributedTransactionOperationType(false)).thenReturn(DistributedTransactionOperationType.BEGIN);
when(connectionTransaction.getTransactionType()).thenReturn(TransactionType.XA);
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
final DriverDatabaseConnectionManager databaseConnectionManager =
mockConnectionManager(connection, connectionTransaction);
connection.setAutoCommit(false);
assertFalse(connection.getAutoCommit());
@@ -142,14 +142,14 @@ class ShardingSphereConnectionTest {
@Test
void assertIsValidWhenEmptyConnection() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
assertTrue(connection.isValid(0));
}
}
@Test
void assertIsInvalid() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY);
assertFalse(connection.isValid(0));
}
@@ -157,7 +157,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetReadOnly() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
assertFalse(connection.isReadOnly());
Connection physicalConnection =
connection.getDatabaseConnectionManager().getConnections(DefaultDatabase.LOGIC_NAME,
"ds", 0, 1, ConnectionMode.MEMORY_STRICTLY).get(0);
connection.setReadOnly(true);
@@ -168,7 +168,7 @@ class ShardingSphereConnectionTest {
@Test
void assertGetTransactionIsolationWithoutCachedConnections() throws
SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
assertThat(connection.getTransactionIsolation(),
is(Connection.TRANSACTION_READ_UNCOMMITTED));
}
@@ -176,7 +176,7 @@ class ShardingSphereConnectionTest {
@Test
void assertSetTransactionIsolation() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
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);
@@ -185,7 +185,7 @@ class ShardingSphereConnectionTest {
@Test
void assertClose() throws SQLException {
- try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager())) {
+ try (ShardingSphereConnection connection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, mockContextManager(),
null)) {
connection.close();
assertTrue(connection.isClosed());
}
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
index 3ca5d91ed07..91d0144f685 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationConnectionTest.java
@@ -44,7 +44,7 @@ class UnsupportedOperationConnectionTest {
void setUp() {
ContextManager contextManager = mock(ContextManager.class,
RETURNS_DEEP_STUBS);
when(contextManager.getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(new
RuleMetaData(Collections.singleton(mock(TransactionRule.class,
RETURNS_DEEP_STUBS))));
- shardingSphereConnection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, contextManager);
+ shardingSphereConnection = new
ShardingSphereConnection(DefaultDatabase.LOGIC_NAME, contextManager, null);
}
@SuppressWarnings("JDBCResourceOpenedButNotSafelyClosed")
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
index 72f76d7219a..c042e94bd0f 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationPreparedStatementTest.java
@@ -58,7 +58,7 @@ class UnsupportedOperationPreparedStatementTest {
when(connection.getContextManager().getMetaDataContexts().getMetaData().getDatabase(
connection.getCurrentDatabaseName()).getProtocolType()).thenReturn(TypedSPILoader.getService(DatabaseType.class,
"MySQL"));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
- shardingSpherePreparedStatement = new
ShardingSpherePreparedStatement(connection, "SELECT 1");
+ shardingSpherePreparedStatement = new
ShardingSpherePreparedStatement(connection, "SELECT 1", null);
}
@Test
diff --git
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
index 68100658470..d1407916d5d 100644
---
a/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
+++
b/jdbc/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationStatementTest.java
@@ -55,7 +55,7 @@ class UnsupportedOperationStatementTest {
new SQLFederationRule(new
DefaultSQLFederationRuleConfigurationBuilder().build(), Collections.emptyMap()),
new SQLParserRule(new
DefaultSQLParserRuleConfigurationBuilder().build()))));
when(connection.getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(new
ConfigurationProperties(new Properties()));
- shardingSphereStatement = new ShardingSphereStatement(connection);
+ shardingSphereStatement = new ShardingSphereStatement(connection,
null);
}
@Test