Example for 1.x please see tags in https://github.com/apache/shardingsphere/tree/${tag}/shardingsphere-jdbc-example
Example for 2.x or 3.x or 4.x please see tags in https://github.com/apache/shardingsphere-example/tree/${tag}
Notices
-
Please do not use
dev
branch to run your example, example ofdev
branch is not released yet. -
Please execute initial script before you first run the example if using manual mode.
-
Please make sure primary replica data replication sync on MySQL is running correctly. Otherwise, primary-replica example will query empty data from the replica.
Please make sure some dependencies from Apache ShardingSphere has been installed since examples depend on that. if you are a newbie for Apache ShardingSphere, you could prepare the dependencies as following:
- download and install Apache ShardingSphere:
## download source code
git clone https://github.com/apache/shardingsphere.git
## compile source code
cd shardingsphere/examples
mvn clean install -Prelease
shardingsphere-example
├── example-core
│ ├── config-utility
│ ├── example-api
│ ├── example-raw-jdbc
│ ├── example-spring-jpa
│ └── example-spring-mybatis
├── shardingsphere-jdbc-example
│ ├── sharding-example
│ │ ├── sharding-raw-jdbc-example
│ │ ├── sharding-spring-boot-jpa-example
│ │ ├── sharding-spring-boot-mybatis-example
│ │ ├── sharding-spring-namespace-jpa-example
│ │ └── sharding-spring-namespace-mybatis-example
│ ├── governance-example
│ │ ├── governance-raw-jdbc-example
│ │ ├── governance-spring-boot-example
│ │ └── governance-spring-namespace-example
│ ├── transaction-example
│ │ ├── transaction-2pc-xa-example
│ │ └── transaction-base-seata-example
│ ├── other-feature-example
│ │ ├── hint-example
│ │ └── encrypt-example
├── shardingsphere-proxy-example
│ ├── shardingsphere-proxy-boot-mybatis-example
│ └── shardingsphere-proxy-hint-example
└── src/resources
└── manual_schema.sql
Example | Description |
---|---|
sharding | show how to use table sharding\database sharding\replica-query with ShardingSphere-JDBC |
springboot jpa | show how to use SpringBoot JPA with ShardingSphere-JDBC |
springboot mybatis | show how to use SpringBoot Mybatis with ShardingSphere-JDBC |
governance | show how to use ShardingSphere-JDBC governance |
transaction | show how to use ShardingSphere-JDBC transaction |
hint | show how to use ShardingSphere-JDBC hint |
encryption | show how to use ShardingSphere-JDBC encryption |
APM(Pending) | show how to use APM in ShardingSphere |
proxy(Pending) | show how to use ShardingSphere-Proxy |
docker | show how to use docker to setup the environment for ShardingSphere |