基于sharding

网友投稿 470 2022-11-27

基于sharding

基于sharding

目录使用限制JDBC未支持列表DataSource接口Connection接口Statement和PreparedStatement接口对于ResultSet接口JDBC 4.1SQL语句限制shardingjdbc使用及踩坑内容1.使用shardingjdbc做分库分表2.踩坑内容

使用限制

JDBC未支持列表

Sharding-JDBC暂时未支持不常用的JDBC方法

DataSource接口

不支持timeout相关操作

Connection接口

不支持存储过程,函数,游标的操作

不支持执行native的SQL

不支持savepoint相关操作

不支持Schema/Catalog的操作

不支持自定义类型映射

Statement和PreparedStatement接口

不支持返回多结果集的语句(即存储过程,非SELECT多条数据)

不支持国际化字符的操作

对于ResultSet接口

不支持对于结果集指针位置判断

不支持通过非next方法改变结果指针位置

不支持修改结果集内容

不支持获取国际化字符

不支持获取Array

JDBC 4.1

不支持JDBC 4.1接口新功能

查询所有未支持方法,请阅读com.dangdang.ddframe.rdb.sharding.jdbc.unsupported包。

SQL语句限制

不支持DDL语句

不支持子语句

不支持UNION 和 UNION ALL

不支持特殊INSERT

每条INSERT语句只能插入一条数据,不支持VALUES后有多行数据的语句

不支持DISTINCT聚合

shardingjdbc使用及踩坑内容

1.使用shardingjdbc做分库分表

最近公司由于业务需要,对日益增加的数据量越来越无法容忍,遂作出分库分表的决定,考察了几个技术方案后,决定使用shardingsphere做分表中间件。

使用maven拉取jar包:

io.shardingsphere

sharding-jdbc

3.0.0.M3

io.shardingsphere

sharding-jdbc-spring-namespace

3.0.0.M3

分表配置:

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:tx="http://springframework.org/schema/tx"

xmlns:sharding="http://shardingsphere.io/schema/shardingspherkcnqZAjRie/sharding"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-3.2.xsd

http://shardingsphere.io/schema/shardingsphere/sharding

http://shardingsphere.io/schema/shardingsphere/sharding/sharding.xsd"

default-autowire=kcnqZAjRi"byName">

sharding-columns="uid"

algorithm-ref="tableShardingAlgorithm" />

logic-table="test_table"

actual-data-nodes="ds_0.test_table_$->{0..128}"

table-strategy-ref="tableStrategy" />

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xmlns:tx="http://springframework.org/schema/tx"

xmlns:sharding="http://shardingsphere.io/schema/shardingspherkcnqZAjRie/sharding"

xsi:schemaLocation="http://springframework.org/schema/beans

http://springframework.org/schema/beans/spring-beans-3.2.xsd

http://springframework.org/schema/tx http://springframework.org/schema/tx/spring-tx-3.2.xsd

http://shardingsphere.io/schema/shardingsphere/sharding

http://shardingsphere.io/schema/shardingsphere/sharding/sharding.xsd"

default-autowire=kcnqZAjRi"byName">

sharding-columns="uid"

algorithm-ref="tableShardingAlgorithm" />

logic-table="test_table"

actual-data-nodes="ds_0.test_table_$->{0..128}"

table-strategy-ref="tableStrategy" />

sharding-columns="uid"

algorithm-ref="tableShardingAlgorithm" />

logic-table="test_table"

actual-data-nodes="ds_0.test_table_$->{0..128}"

table-strategy-ref="tableStrategy" />

logic-table="test_table"

actual-data-nodes="ds_0.test_table_$->{0..128}"

table-strategy-ref="tableStrategy" />

2.踩坑内容

1). 用于分表的列在sql中不能为空,所以像insert之类的语句需要做下非空判断;

2). sqlmap中LONGVARCHER字段不能使用,会报序列化异常,可改为VARCHAR类型;

3). union语法不支持,可改为OR查询(shardingjdbc连OR也不支持,所以建议使用shardingsphere)。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:ASP.NET Aries 2.0 发布(原来的源码SVN已关闭,开源源码已迁移到GitHub)
下一篇:CYQ.Data V5 从入门到放弃ORM系列:教程 - Log、SysLogs两个日志类使用
相关文章

 发表评论

暂时没有评论,来抢沙发吧~