sharding-jdbc 5.0.0 单库分表接入,使用information_schema查询mysql数据库是否存在表时,抛出异常 Cause: org.apache.shardingsphere.infra.exception.SchemaNotExistedException: Schema ‘information_schema’ doesn’t exist.,请问怎么解决?
# 数据源配置
dataSources:
ds0:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://test.server.com:3306/sharding-jdbc-demo?tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowMultiQueries=true&useOldAliasMetadataBehavior=true&autoReconnect=true&failOverReadOnly=false
username: root
password: 123456
# 初始连接数
initialSize: 20
# 最小连接池数量
minIdle: 20
# 最大连接池数量
maxActive: 300
# 分表规则配置
rules:
- !SHARDING
tables:
# 逻辑表
b_device_issue_msg_history:
# 真实分片表
actualDataNodes: ds0.b_device_issue_msg_history_20210${1..4}
# 分表策略
tableStrategy:
standard:
# 分片键
shardingColumn: create_time
# 分片算法关联
shardingAlgorithmName: b_device_issue_msg_history_inline
# 分片算法配置
shardingAlgorithms:
b_device_issue_msg_history_inline:
# 分片算法类型
type: INTERVAL
# 分片算法属性配置
props:
datetime-pattern: 'yyyy-MM-dd HH:mm:ss'
datetime-lower: '2021-01-01 00:00:00'
datetime-upper: '2021-12-31 23:59:59'
sharding-suffix-pattern: 'yyyyQQ'
datetime-interval-amount: '3'
datetime-interval-unit: 'months'
# sharding-jdbc 属性配置
props:
# 是否打印sql输出控制台
sql-show: true
查询语句(在未接入sharding-jdbc前可以正常查询)
SELECT COUNT(1)
FROM information_schema.tables
WHERE table_name = #{tableName} and table_schema = 'gb_manage_os'
异常信息
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.shardingsphere.infra.exception.SchemaNotExistedException: Schema 'information_schema' doesn't exist.
### The error may exist in file [D:\DevCodeHome\gb-manage-os\target\classes\cn\greenbon\account\dao\AuthFansMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT COUNT(1) FROM information_schema.tables WHERE table_name = ? and table_schema = 'gb_manage_os'
### Cause: org.apache.shardingsphere.infra.exception.SchemaNotExistedException: Schema 'information_schema' doesn't exist.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
at com.sun.proxy.$Proxy348.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:159)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:108)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:96)
at com.sun.proxy.$Proxy428.checkTableExists(Unknown Source)
at cn.greenbon.account.service.impl.AuthFansServiceImpl.checkTableExists(AuthFansServiceImpl.java:73)
at cn.greenbon.account.service.impl.AuthFansServiceImpl.checkAndCreateNewTable(AuthFansServiceImpl.java:80)
at cn.greenbon.account.service.impl.AuthFansServiceImpl.initAuthTable(AuthFansServiceImpl.java:100)
at cn.greenbon.account.service.impl.AuthFansServiceImpl$$FastClassBySpringCGLIB$$e62e48e6.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
at cn.greenbon.account.service.impl.AuthFansServiceImpl$$EnhancerBySpringCGLIB$$9be1ab0d.initAuthTable(<generated>)
at cn.greenbon.main.InitWxConfiguration.run(InitWxConfiguration.java:30)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:786)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at cn.greenbon.main.ManageApplication.main(ManageApplication.java:39)