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 c5c5aaa Schema name properties xml jdbc (#11655)
c5c5aaa is described below
commit c5c5aaa7261d172f7f7bb65512c2b0f9b3155015
Author: zhaojinchao <[email protected]>
AuthorDate: Thu Aug 5 15:11:16 2021 +0800
Schema name properties xml jdbc (#11655)
* shardingsphere-jdbc-core yml config add schemaName
* update
* modify todo
* update
* properties and xml add schema name
* reset code
* add final
* first letter capitalized
---
.../jdbc/config/ShadowDatabasesConfiguration.java | 3 +-
.../core/datasource/ShardingSphereDataSource.java | 10 -----
.../driver/jdbc/adapter/WrapperAdapterTest.java | 3 +-
.../datasource/ShardingSphereDataSourceTest.java | 3 +-
.../UnsupportedOperationDataSourceTest.java | 3 +-
.../boot/ShardingSphereAutoConfiguration.java | 8 ++--
.../test/resources/application-common.properties | 2 +
.../parser/DataSourceBeanDefinitionParser.java | 9 +++++
.../namespace/tag/SchemaNameBeanDefinitionTag.java | 30 +++++++++++++++
.../resources/META-INF/namespace/datasource.xsd | 1 +
.../META-INF/spring/application-context.xml | 2 +-
.../spring/boot/schema/SchemaNameSetter.java | 45 ++++++++++++++++++++++
.../spring/boot/schema/SchemaNameSetterTest.java | 39 +++++++++++++++++++
.../test/mysql/env/config/SourceConfiguration.java | 2 +-
14 files changed, 141 insertions(+), 19 deletions(-)
diff --git
a/examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
b/examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
index c851209..0633467 100644
---
a/examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
+++
b/examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/table/raw/jdbc/config/ShadowDatabasesConfiguration.java
@@ -19,6 +19,7 @@ package
org.apache.shardingsphere.example.shadow.table.raw.jdbc.config;
import org.apache.shardingsphere.example.config.ExampleConfiguration;
import org.apache.shardingsphere.example.core.api.DataSourceUtil;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
@@ -36,6 +37,6 @@ public final class ShadowDatabasesConfiguration implements
ExampleConfiguration
Map<String, DataSource> dataSourceMap = new HashMap<>(2, 1);
dataSourceMap.put("ds", DataSourceUtil.createDataSource("demo_ds"));
dataSourceMap.put("ds_0",
DataSourceUtil.createDataSource("shadow_demo_ds"));
- return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
Collections.singleton(shadowRuleConfig), null);
+ return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
Collections.singleton(shadowRuleConfig), null, DefaultSchema.LOGIC_NAME);
}
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
index 654608a..726429d 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSource.java
@@ -57,16 +57,6 @@ public final class ShardingSphereDataSource extends
AbstractUnsupportedOperation
private final String schemaName;
- //TODO remove this when complete load namespace
- public ShardingSphereDataSource(final Map<String, DataSource>
dataSourceMap, final Collection<RuleConfiguration> ruleConfigs, final
Properties props) throws SQLException {
- this.schemaName = DefaultSchema.LOGIC_NAME;
- DistMetaDataPersistRepository repository =
DistMetaDataPersistRepositoryFactory.newInstance(findDistMetaDataPersistRuleConfiguration(ruleConfigs));
- metaDataContexts = new
MetaDataContextsBuilder(Collections.singletonMap(DefaultSchema.LOGIC_NAME,
dataSourceMap),
- Collections.singletonMap(DefaultSchema.LOGIC_NAME,
ruleConfigs), props).build(new DistMetaDataPersistService(repository));
- String xaTransactionMangerType =
metaDataContexts.getProps().getValue(ConfigurationPropertyKey.XA_TRANSACTION_MANAGER_TYPE);
- transactionContexts =
createTransactionContexts(metaDataContexts.getDefaultMetaData().getResource().getDatabaseType(),
dataSourceMap, xaTransactionMangerType);
- }
-
public ShardingSphereDataSource(final Map<String, DataSource>
dataSourceMap, final Collection<RuleConfiguration> ruleConfigs, final
Properties props, final String schemaName) throws SQLException {
this.schemaName = getSchemaName(schemaName);
DistMetaDataPersistRepository repository =
DistMetaDataPersistRepositoryFactory.newInstance(findDistMetaDataPersistRuleConfiguration(ruleConfigs));
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
index ecaefdd..8a6f8dc 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/adapter/WrapperAdapterTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.driver.jdbc.adapter;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.junit.Before;
import org.junit.Test;
@@ -42,7 +43,7 @@ public final class WrapperAdapterTest {
@Before
public void setUp() throws SQLException {
- shardingSphereDataSource = new
ShardingSphereDataSource(Collections.emptyMap(), Collections.emptyList(), new
Properties());
+ shardingSphereDataSource = new
ShardingSphereDataSource(Collections.emptyMap(), Collections.emptyList(), new
Properties(), DefaultSchema.LOGIC_NAME);
}
@Test
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
index bb8d76e..ae3ce7e 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/core/datasource/ShardingSphereDataSourceTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.driver.jdbc.core.datasource;
import com.google.common.base.Joiner;
import
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection;
import
org.apache.shardingsphere.driver.jdbc.core.fixture.XAShardingTransactionManagerFixture;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeRegistry;
import org.apache.shardingsphere.infra.database.type.dialect.H2DatabaseType;
@@ -179,7 +180,7 @@ public final class ShardingSphereDataSourceTest {
}
private ShardingSphereDataSource createShardingSphereDataSource(final
Map<String, DataSource> dataSourceMap) throws SQLException {
- return new ShardingSphereDataSource(dataSourceMap,
Collections.singletonList(createShardingRuleConfig(dataSourceMap)), new
Properties());
+ return new ShardingSphereDataSource(dataSourceMap,
Collections.singletonList(createShardingRuleConfig(dataSourceMap)), new
Properties(), DefaultSchema.LOGIC_NAME);
}
private ShardingRuleConfiguration createShardingRuleConfig(final
Map<String, DataSource> dataSourceMap) {
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
index c7f961e..f8dadc8 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/test/java/org/apache/shardingsphere/driver/jdbc/unsupported/UnsupportedOperationDataSourceTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.driver.jdbc.unsupported;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.junit.Before;
import org.junit.Test;
@@ -32,7 +33,7 @@ public final class UnsupportedOperationDataSourceTest {
@Before
public void setUp() throws SQLException {
- shardingSphereDataSource = new
ShardingSphereDataSource(Collections.emptyMap(), Collections.emptyList(), new
Properties());
+ shardingSphereDataSource = new
ShardingSphereDataSource(Collections.emptyMap(), Collections.emptyList(), new
Properties(), DefaultSchema.LOGIC_NAME);
}
@Test(expected = SQLFeatureNotSupportedException.class)
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
index 41efa4e..8567083 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/main/java/org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.java
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.spring.boot;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.database.DefaultSchema;
import org.apache.shardingsphere.spring.boot.datasource.DataSourceMapSetter;
import
org.apache.shardingsphere.spring.boot.prop.SpringBootPropertiesConfiguration;
+import org.apache.shardingsphere.spring.boot.schema.SchemaNameSetter;
import
org.apache.shardingsphere.spring.transaction.ShardingTransactionTypeScanner;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
@@ -60,6 +60,8 @@ public class ShardingSphereAutoConfiguration implements
EnvironmentAware {
private final Map<String, DataSource> dataSourceMap = new
LinkedHashMap<>();
+ private String schemaName;
+
/**
* Get ShardingSphere data source bean.
*
@@ -71,8 +73,7 @@ public class ShardingSphereAutoConfiguration implements
EnvironmentAware {
@Autowired(required = false)
public DataSource shardingSphereDataSource(final
ObjectProvider<List<RuleConfiguration>> rules) throws SQLException {
Collection<RuleConfiguration> ruleConfigurations =
Optional.ofNullable(rules.getIfAvailable()).orElse(Collections.emptyList());
- //TODO get schema name by properties
- return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
ruleConfigurations, props.getProps(), DefaultSchema.LOGIC_NAME);
+ return ShardingSphereDataSourceFactory.createDataSource(dataSourceMap,
ruleConfigurations, props.getProps(), schemaName);
}
/**
@@ -88,5 +89,6 @@ public class ShardingSphereAutoConfiguration implements
EnvironmentAware {
@Override
public final void setEnvironment(final Environment environment) {
dataSourceMap.putAll(DataSourceMapSetter.getDataSourceMap(environment));
+ schemaName = SchemaNameSetter.getSchemaName(environment);
}
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
index 4cd2698..bef8aaa 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-boot-starter/src/test/resources/application-common.properties
@@ -15,6 +15,8 @@
# limitations under the License.
#
+spring.shardingsphere.schema.name=logic_db
+
spring.shardingsphere.datasource.names=ds_${0..1}
spring.shardingsphere.datasource.ds_0.type=org.apache.shardingsphere.test.mock.MockedDataSource
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
index e48a028..3044a08 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
@@ -19,7 +19,9 @@ package org.apache.shardingsphere.spring.namespace.parser;
import com.google.common.base.Splitter;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
+import org.apache.shardingsphere.infra.database.DefaultSchema;
import
org.apache.shardingsphere.spring.namespace.tag.DataSourceBeanDefinitionTag;
+import
org.apache.shardingsphere.spring.namespace.tag.SchemaNameBeanDefinitionTag;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -27,6 +29,7 @@ import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
@@ -46,6 +49,7 @@ public final class DataSourceBeanDefinitionParser extends
AbstractBeanDefinition
factory.addConstructorArgValue(parseDataSources(element));
factory.addConstructorArgValue(parseRuleConfigurations(element));
factory.addConstructorArgValue(parseProperties(element,
parserContext));
+ factory.addConstructorArgValue(parseSchemaName(element));
factory.setDestroyMethodName("close");
return factory.getBeanDefinition();
}
@@ -72,4 +76,9 @@ public final class DataSourceBeanDefinitionParser extends
AbstractBeanDefinition
Element propsElement = DomUtils.getChildElementByTagName(element,
DataSourceBeanDefinitionTag.PROPS_TAG);
return null == propsElement ? new Properties() :
parserContext.getDelegate().parsePropsElement(propsElement);
}
+
+ private String parseSchemaName(final Element element) {
+ String schemaName =
element.getAttribute(SchemaNameBeanDefinitionTag.ROOT_TAG);
+ return StringUtils.isEmpty(schemaName) ? DefaultSchema.LOGIC_NAME :
schemaName;
+ }
}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/tag/SchemaNameBeanDefinitionTag.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/tag/SchemaNameBeanDefinitionTag.java
new file mode 100644
index 0000000..43eff22
--- /dev/null
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/tag/SchemaNameBeanDefinitionTag.java
@@ -0,0 +1,30 @@
+/*
+ * 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.spring.namespace.tag;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+/**
+ * Schema name bean definition tag.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SchemaNameBeanDefinitionTag {
+
+ public static final String ROOT_TAG = "schema-name";
+}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
index 0941fda..22bab05 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
@@ -31,6 +31,7 @@
<xsd:attribute name="id" type="xsd:string" use="required" />
<xsd:attribute name="data-source-names" type="xsd:string"
use="required" />
<xsd:attribute name="rule-refs" type="xsd:string" use="required" />
+ <xsd:attribute name="schema-name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
index 8290e3b..d1ded5c 100644
---
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
@@ -82,7 +82,7 @@
<readwrite-splitting:data-source-rule id="ds_1"
write-data-source-name="ds_1_write"
read-data-source-names="ds_1_read_0,ds_1_read_1" />
</readwrite-splitting:rule>
- <shardingsphere:data-source id="dataSource"
data-source-names="ds_0_write,ds_0_read_0,ds_0_read_1,ds_1_write,ds_1_read_0,ds_1_read_1"
rule-refs="shardingRule, readWriteSplittingRule, encryptRule">
+ <shardingsphere:data-source id="dataSource"
data-source-names="ds_0_write,ds_0_read_0,ds_0_read_1,ds_1_write,ds_1_read_0,ds_1_read_1"
rule-refs="shardingRule, readWriteSplittingRule, encryptRule"
schema-name="logic_db">
<props>
<prop key="sql-show">false</prop>
<prop key="executor-size">${executor-size}</prop>
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetter.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetter.java
new file mode 100644
index 0000000..206fbaf
--- /dev/null
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/main/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetter.java
@@ -0,0 +1,45 @@
+/*
+ * 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.spring.boot.schema;
+
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.StandardEnvironment;
+
+/**
+ * Schema name setter.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SchemaNameSetter {
+
+ private static final String PREFIX = "spring.shardingsphere.schema.";
+
+ private static final String SCHEMA_NAME = "name";
+
+ /**
+ * Get schema name.
+ *
+ * @param environment spring boot environment
+ * @return schema name
+ */
+ public static String getSchemaName(final Environment environment) {
+ StandardEnvironment standardEnv = (StandardEnvironment) environment;
+ return standardEnv.getProperty(PREFIX + SCHEMA_NAME);
+ }
+}
diff --git
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetterTest.java
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetterTest.java
new file mode 100644
index 0000000..7a5ae79
--- /dev/null
+++
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-boot-starter-infra/src/test/java/org/apache/shardingsphere/spring/boot/schema/SchemaNameSetterTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.spring.boot.schema;
+
+import org.junit.Test;
+import org.springframework.core.env.StandardEnvironment;
+import org.springframework.mock.env.MockEnvironment;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class SchemaNameSetterTest {
+
+ @Test
+ public void assertSchemaName() {
+ MockEnvironment mockEnvironment = new MockEnvironment();
+ mockEnvironment.setProperty("spring.shardingsphere.schema.name",
"jdbc_db");
+ StandardEnvironment standardEnvironment = new StandardEnvironment();
+ standardEnvironment.merge(mockEnvironment);
+ String schemaName =
SchemaNameSetter.getSchemaName(standardEnvironment);
+ assertThat(schemaName, is("jdbc_db"));
+
+ }
+}
diff --git
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
index efa5066..32b1d2f 100644
---
a/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
+++
b/shardingsphere-test/shardingsphere-integration-scaling-test/shardingsphere-integration-scaling-test-mysql/src/test/java/org/apache/shardingsphere/integration/scaling/test/mysql/env/config/SourceConfiguration.java
@@ -94,6 +94,6 @@ public final class SourceConfiguration {
public static DataSource createHostDataSource(final Map<String,
YamlTableRuleConfiguration> tableRules) {
ShardingSphereJDBCDataSourceConfiguration configuration =
getHostConfiguration(tableRules);
return new ShardingSphereDataSource(new
YamlDataSourceConfigurationSwapper().swapToDataSources(configuration.getRootRuleConfigs().getDataSources()),
- new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configuration.getRootRuleConfigs().getRules()),
null);
+ new
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(configuration.getRootRuleConfigs().getRules()),
null, null);
}
}