本文说下shardingsphere使用oracle数据库下的各种问题。
环境:springboot2.2.10.RELEASE+mybatis+jpa+shardingsphere4.1.1
1、配置文件
- pom.xml
1.84.1.1org.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-data-jpaorg.mybatis.spring.bootmybatis-spring-boot-starter2.1.3com.github.pagehelperpagehelper4.1.3org.apache.shardingspheresharding-jdbc-spring-boot-starter${shardingsphere.version}com.github.norauiojdbc712.1.0.2
- application.yml
server: port: 9900---spring: shardingsphere: enabled: true props: sql: show: true datasource: names: ds0 ds0: type: com.zaxxer.hikari.HikariDataSource driverClassName: oracle.jdbc.OracleDriver #com.mysql.cj.jdbc.Driver jdbcUrl: jdbc:oracle:thin:@10.100.102.113:1521/orcl #jdbc:mysql://localhost:3306/ds0?serverTimezone=GMT%2B8 username: empi #root password: empi #123123 minimumIdle: 10 maximumPoolSize: 200 autoCommit: true idleTimeout: 30000 poolName: DS0DatabookHikariCP maxLifetime: 1800000 connectionTimeout: 30000 connectionTestQuery: SELECT 1 FROM DUAL sharding: tables: t_order: #逻辑表名 actualDataNodes: ds$->{0}.t_order_$->{2020..2020}0$->{1..9}, ds$->{0}.t_order_$->{2020..2020}$->{10..12} #实际表 tableStrategy: #分表策略 standard: #标准分片策略 shardingColumn: order_date #分片字段 preciseAlgorithmClassName: com.pack.sharding.algorithm.DateTableShardingAlgorithm rangeAlgorithmClassName: com.pack.sharding.algorithm.DataTabeRangeShardingAlgorithm t_product: actualDataNodes: ds$->{0}.t_product_$->{0..1} tableStrategy: inline: shardingColumn: id algorithmExpression: t_product_$->{id & 1} t_comment: actualDataNodes: ds$->{0}.t_comment_$->{0..1} t