Please refer to the usage examples of Sharding-JDBC in Usage Example
Please run resources/manual_shcema.sql on the test MySQL database to automatically create the database for testing. If PostgreSQL, SQLServer, or Oracle is used, you need to create test database by running your scripts.
Users need to modify the database URL, driver, username, password, yaml or Spring configuration in the example.
In the example of Read-write splitting, user needs to build the Master-Slave replication relationship of the databases, otherwise the null value will be obtained when querying in the Slave.
io.shardingjdbc.example.jdbc.java.RawJdbcJavaMasterSlaveOnlyMain
io.shardingjdbc.example.jdbc.java.RawJdbcJavaShardingDatabaseAndTableMain
io.shardingjdbc.example.jdbc.java.RawJdbcJavaShardingDatabaseOnlyMain
io.shardingjdbc.example.jdbc.java.RawJdbcJavaShardingTableOnlyMain
io.shardingjdbc.example.jdbc.java.RawJdbcJavaShardingAndMasterSlaveMain
io.shardingjdbc.example.jdbc.yaml.RawJdbcYamlMasterSlaveOnlyMain
io.shardingjdbc.example.jdbc.yaml.RawJdbcYamlShardingDatabaseAndTableMain
io.shardingjdbc.example.jdbc.yaml.RawJdbcYamlShardingDatabaseOnlyMain
io.shardingjdbc.example.jdbc.yaml.RawJdbcYamlShardingTableOnlyMain
io.shardingjdbc.example.jdbc.yaml.RawJdbcYamlShardingAndMasterSlaveMain
io.shardingjdbc.example.spring.namespace.jpa.SpringJpaMasterSlaveOnlyMain
io.shardingjdbc.example.spring.namespace.jpa.SpringJpaShardingDatabaseAndTableMain
io.shardingjdbc.example.spring.namespace.jpa.SpringJpaShardingDatabaseOnlyMain
io.shardingjdbc.example.spring.namespace.jpa.SpringJpaShardingTableMain
io.shardingjdbc.example.spring.namespace.jpa.SpringJpaShardingDatabaseAndMasterSlaveMain
io.shardingjdbc.example.spring.namespace.jpa.SpringMybatisMasterSlaveOnlyMain
io.shardingjdbc.example.spring.namespace.jpa.SpringMybatisShardingDatabaseAndTableMain
io.shardingjdbc.example.spring.namespace.jpa.SpringMybatisShardingDatabaseOnlyMain
io.shardingjdbc.example.spring.namespace.jpa.SpringMybatisShardingTableMain
io.shardingjdbc.example.spring.namespace.jpa.SpringMybatisShardingDatabaseAndMasterSlaveMain
io.shardingjdbc.example.spring.boot.starter.jpa.SpringBootDataJpaMain
To switch example configuration by modifying spring.profiles.active in resources/applicaiton.properties file.
spring.profiles.active=sharding
#spring.profiles.active=sharding-db
#spring.profiles.active=sharding-tbl
#spring.profiles.active=masterslave
#spring.profiles.active=sharding-masterslave
io.shardingjdbc.example.spring.boot.jpa.SpringBootDataMybatisMain
To switch example configuration by modifying spring.profiles.active in resources/applicaiton.properties file.
spring.profiles.active=sharding
#spring.profiles.active=sharding-db
#spring.profiles.active=sharding-tbl
#spring.profiles.active=masterslave
#spring.profiles.active=sharding-masterslave
To set up Zookeeper environment, whose address in this example is localhost:2181.
io.shardingjdbc.example.orchestration.OrchestrationShardingMain
io.shardingjdbc.example.orchestration.yaml.OrchestrationYamlShardingMain
io.shardingjdbc.example.orchestration.spring.namespace.OrchestrationSpringMybatisShardingShardingMain
io.shardingjdbc.example.orchestration.spring.boot.OrchestrationSpringBootDataJpaMain
io.shardingjdbc.example.transaction.TransactionMain