Closed wpd-static closed 1 year ago
Hi @wpd-static, can you submit issue according to issue template?
In a java test project,springboot project,the pom file is imported,`
<artifactId>mysql-connector-java</artifactId>
<version>8.0.32</version>
<scope>runtime</scope>
</dependency>`,`<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>5.2.0</version>
</dependency>`,` <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.3</version>
<relativePath/>
</parent>`.
The test code is,
ObString obString = new ObString(); obString.setId(MyIdUtil.getSnowflakeNextId()); obString.setRefId(1704678770319065096L); obString.setName("测试"); obString.setValue("测试"); String sql = "INSERT INTO ob_string (id,name, value, ref_id) VALUES (?, ?, ?, ?)"; jdbcTemplate.update(sql, obString.getId(), obString.getName(), obString.getValue(), obString.getRefId());
in JdbcTemplate execute 427 row, ps = psc.createPreparedStatement(con);
No execution ShardingSpherePreparedStatement,i'm sorry to trouble you
yaml file: spring:
datasource: type: com.zaxxer.hikari.HikariDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/stu?characterEncoding=utf-8&userSSL=false&serverTimezone=Asia/Shanghai username: root password: root
shardingsphere:
datasource:
# 数据源名称,多数据源以逗号分隔 ,放在第一个的数据源为未配置分片规则表的默认数据源
names: db0
db0:
# 数据库连接池类名称
type: com.zaxxer.hikari.HikariDataSource
# 数据库驱动类名
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://localhost:3306/stu?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: root
# 规则配置
rules:
sharding:
# 设置默认数据源
default-data-source-name: db0
tables:
ob_string:
actual-data-nodes: db0.ob_string_$->{0..15}
table-strategy:
standard:
sharding-column: ref_id
sharding-algorithm-name: ob-string-inline
# 分片算法配置
sharding-algorithms:
ob-string-inline:
type: INLINE
props:
algorithm-expression: ob_string_$->{ref_id % 16}
# 分布式序列算法配置
# 属性配置
props:
# 展示修改以后的sql语句
sql-show: true
table
<artifactId>mysql-connector-java</artifactId>
**<version>5.1.49</version>**
<scope>runtime</scope>
</dependency>`, Correct code execution, Actual SQL: db0 ::: INSERT INTO ob_string_8 (id,name, value, ref_id) VALUES (?, ?, ?, ?) ::: [1706296697183092748, 测试, 测试, 1704678770319065096]
Only support english to ask question, i will close it, you can create a new issue with english.
Question
For English only, other languages will not accept.
Before asking a question, make sure you have:
Please pay attention on issues you submitted, because we maybe need more details. If no response anymore and we cannot reproduce it on current information, we will close it.