https://github.com/hellojavaer/ddal
DDAL(Distributed Data Access Layer) is a simple solution to access database shard.
https://github.com/hellojavaer/ddal
access-database-shard converter datasource ddr distributed load-balancer mysql schema sequence shard sql transaction
Last synced: 3 months ago
JSON representation
DDAL(Distributed Data Access Layer) is a simple solution to access database shard.
- Host: GitHub
- URL: https://github.com/hellojavaer/ddal
- Owner: hellojavaer
- License: apache-2.0
- Created: 2016-11-18T17:26:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-06-15T17:50:38.000Z (almost 8 years ago)
- Last Synced: 2025-07-05T11:48:19.553Z (9 months ago)
- Topics: access-database-shard, converter, datasource, ddr, distributed, load-balancer, mysql, schema, sequence, shard, sql, transaction
- Language: Java
- Homepage:
- Size: 1.78 MB
- Stars: 34
- Watchers: 8
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DDAL
[](https://travis-ci.org/hellojavaer/ddal)
[](https://github.com/hellojavaer/ddal/releases)
[](https://maven-badges.herokuapp.com/maven-central/org.hellojavaer.ddal/ddal-datasource/)
DDAL(Distributed Data Access Layer) is a simple solution to access database shard.

## License
DDAL is dual licensed under **LGPL V2.1** and **Apache Software License, Version 2.0**.
## Quick start
- add the following dependency in your pom.xml
```xml
org.hellojavaer.ddal
ddal-datasource
1.1.1-RELEASE
```
- use DefaultDDALDataSource to proxy the orginal dataSource
```
```
- see [datasource.xml](https://github.com/hellojavaer/ddal/blob/master/ddal-example/ddal-example-example0/src/main/resources/datasource.xml)
- see [a full example](https://github.com/hellojavaer/ddal/tree/master/ddal-example)
## Features
- Only need to proxy the original datasources for business
- Fully support ACID
- Support insert, select, update and delete expression
- Support join(inner join,left join,right join,full jion), sub-select, union all and exists expression
- Support table alias
- Support no shard-key schema/table routing
- Support '=', in' and 'between' operation to route schema/table and support mixed sql parameter and jdbc parameter in routing values
- eg: 'select * from tb where id in(1,?,3)'
- eg: 'select * from tb where id between 1 and ?'
- Support Date, Timestamp, Byte, Short, Integer, Long, String, Character, Hex value type for shard-value
- Support annotation routing
- Support custom route rule (eg: '{scName}_{format('%02d', sdValue % 4)}')
- Support route rule binding on a schema (instead of a table)
- Support scan all schemas and tables
- Support limit check
- Support read-write splitting
- Support load balance of read
- Support config at server-side
- Support db cluster route
- Provide multiple sequence implements
## Download
http://repo1.maven.org/maven2/org/hellojavaer/ddal/
## Documentation
- [Documentation Home](https://github.com/hellojavaer/ddal/wiki)
- [Frequently Asked Questions](https://github.com/hellojavaer/ddal/wiki/faq)
## [Release Notes](https://github.com/hellojavaer/ddal/releases)
## Extensions in the latest version 1.1.0-RELEASE
- support DB cluster route
- enhance ShardRouteUtils
## Extensions in version 1.0.1-RELEASE
- Support route rule binding on a schema (instead of a table)
```
```
## Extensions in version 1.0.0-RELEASE
- upgrade jsqlparser's version to 1.2 to support more sql features
- optimize JSQLParserAdapter
## Extensions in version 1.0.0.M7
- support custom protocol jdbc:ddal:
## Extensions in version 1.0.0.M6
- implement DefaultDDALDataSource in ddal-datasource module
```
```
- implement DivideShardRouteRule for range route
## Extensions in version 1.0.0.M5
- optimize route rule expression parser
```
// older
SpelShardRouteRule rule = new SpelShardRouteRule();
rule.setScRouteRule("{#scName}_{#format('%02d', #sdValue % 4)}");
rule.setTbRouteRule("{#tbName}_{#format('%04d', #sdValue % 8)}");
// newer
SpelShardRouteRule rule = new SpelShardRouteRule();
rule.setScRouteRule("{scName}_{format('%02d', sdValue % 4)}");
rule.setTbRouteRule("{tbName}_{format('%04d', sdValue % 8)}");
```
- optimize range expression parser
```
"1,2,3" => 1,2,3
"[1..3]" => 1,2,3
"['A'..'C','X']" => A,B,C,X
"[0..1][0..1]" => 00,01,10,11
"Hi![' Allen',' Bob']" => Hi! Allen,Hi! Bob
```