Python 官方文档:入门教程 => 点击学习
目录使用限制JDBC未支持列表DataSource接口Connection接口Statement和PreparedStatement接口对于ResultSet接口JDBC 4.1sq
最近公司由于业务需要,对日益增加的数据量越来越无法容忍,遂作出分库分表的决定,考察了几个技术方案后,决定使用shardingsphere做分表中间件。
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc</artifactId>
<version>3.0.0.M3</version>
</dependency>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>3.0.0.M3</version>
</dependency>
分表配置:
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="Http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:sharding="http://shardingsphere.io/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/tx http://www.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="byName">
<!-- 分表算法 -->
<bean id="tableShardingAlGorithm" class="pxf.commom.support.sharding.tableShardingAlgorithm" />
<sharding:complex-strategy id="tableStrategy"
sharding-columns="uid"
algorithm-ref="tableShardingAlgorithm" />
<!-- ds_0为数据源,如果做分库,可配置多个数据源;不分表的表不用在此做配置-->
<sharding:data-source id="dataSource">
<sharding:sharding-rule data-source-names="ds_0" default-data-source-name="ds_0" >
<sharding:table-rules>
<sharding:table-rule
logic-table="test_table"
actual-data-nodes="ds_0.test_table_$->{0..128}"
table-strategy-ref="tableStrategy" />
</sharding:table-rules>
</sharding:sharding-rule>
</sharding:data-source>
</beans>
1). 用于分表的列在sql中不能为空,所以像insert之类的语句需要做下非空判断;
2). sqlmap中LONGVARCHER字段不能使用,会报序列化异常,可改为VARCHAR类型;
3). union语法不支持,可改为OR查询(shardingjdbc连OR也不支持,所以建议使用shardingsphere)。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: 基于sharding-jdbc的使用限制
本文链接: https://www.lsjlt.com/news/155899.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0