by yuanwhy

yuanwhy /simple-sharding

☕️ A simple database shard middleware

131 Stars 42 Forks Last release: Not found 44 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Build Status Join the chat at License

A simple database shard middleware, based on JDBC API. Applications can scale database by using new DataSource with simple-sharding. This project is not finished, and feel free to study.


  • Transaction in single database shard
  • Sharding
  • Rewriting rules

Quick Start

1. Get source code

git clone

and then execute

to init data.

2. Install simple-sharding to you local repository by

mvn clean install

3. Add artifact dependency


4. Set logic datasource and physic datasources

<hashshardingrule id="hashShardingRule" dbcount="2" tablecount="2" fieldnamefordb="role" fieldnamefortable="id"></hashshardingrule>

<logicdatasource id="dataSource" name="passport" shardingrule="hashShardingRule">
    <physicaldatasource name="passport_0" jdbcurl="jdbc:mysql://" user="root" password=""></physicaldatasource>
    <physicaldatasource name="passport_1" jdbcurl="jdbc:mysql://" user="root" password=""></physicaldatasource>

5. Feel free to use JDBC API or ORM framework (e.g. MyBatis ) to execute your SQL


Simple-Sharding 中文



  • [x] Support Spring custom namespace
  • [ ] Finish other methods
  • [ ] Support multiple tables in one datasource


Apache License, Version 2.0

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.