Retro Eye care Haitian Deep Dark Default

ShardingSphere-JDBC

Import Maven Dependency

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>shardingsphere-jdbc-core</artifactId>
    <version>${latest.release.version}</version>
</dependency>

Notice: Please change ${latest.release.version} to the actual version.

Rules Configuration

ShardingSphere-JDBC can be configured by four methods, Java, YAML, Spring namespace and Spring boot starter. Developers can choose the suitable method according to different situations. Please refer to User Manual for more details.

3. Create Data Source

Use ShardingSphereDataSourceFactory and rule configurations to create ShardingSphereDataSource, which implements DataSource interface of JDBC. It can be used for native JDBC or JPA, Hibernate, MyBatis and other ORM frameworks.

DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(schemaName, modeConfig, dataSourceMap, ruleConfigs, props);