BackendConnection implements JDBCExecutionConnection { public void setCurrentSchema(final String schemaName) { if (transactionStatus.isInTransaction()) { throw new ShardingSphereException("Failed to switch schema, please terminate current transaction."); } this.schemaName = schemaName; } BackendConnection(final TransactionType initialTransactionType); void setCurrentSchema(final String schemaName); @Override List<Connection> getConnections(final String dataSourceName, final int connectionSize, final ConnectionMode connectionMode); @Override Statement createStorageResource(final Connection connection, final ConnectionMode connectionMode, final StatementOption option); @Override PreparedStatement createStorageResource(final String sql, final List<Object> parameters, 
                                                   final Connection connection, final ConnectionMode connectionMode, final StatementOption option); boolean isSerialExecute(); int getConnectionSize(); void add(final Statement statement); void add(final ResultSet resultSet); synchronized Collection<SQLException> closeResultSets(); synchronized Collection<SQLException> closeStatements(); synchronized Collection<SQLException> closeConnections(final boolean forceRollback);  }
@Test(expected = ShardingSphereException.class) public void assertFailedSwitchSchemaWhileBegin() { BackendTransactionManager transactionManager = new BackendTransactionManager(backendConnection); transactionManager.begin(); backendConnection.setCurrentSchema("newSchema"); }