zxh-im opened a new issue, #33709:
URL: https://github.com/apache/shardingsphere/issues/33709
The SINGLE table is normal, while the SHARDING table reports an error
**version:**shardingsphere-jdbc 5.5.1
**my yml:**
`dataSources:
db0:
dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.0.39:3306/ry
username: root
password: 123456
rules:
- !SINGLE
tables:
- "*.*"
- !SHARDING
tables:
order_details:
actualDataNodes:
db0.order_details_$->{com.hehui.system.config.sharding.YearMonthShardingAlgorithm.list()}
tableStrategy:
standard:
shardingColumn: createTime
shardingAlgorithmName: test1
shardingAlgorithms:
test1:
type: CLASS_BASED
props:
strategy: standard
algorithmClassName:
com.hehui.system.config.sharding.OrderDetailsShardingAlgorithm
props:
sql-show: true
`
**createDataSource:**
` @Bean
public DataSource masterDataSource(DruidProperties druidProperties)
throws SQLException, IOException {
DataSource dataSource
=YamlShardingSphereDataSourceFactory.createDataSource(ShardingConfig.getShardingYAMLFile());
return dataSource;
}
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name =
"enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
return druidProperties.dataSource(dataSource);
}
@Bean(name = "dynamicDataSource")
@Primary
public DynamicDataSource dataSource(DataSource masterDataSource)
{
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put(DataSourceType.MASTER.name(),
masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(),
"slaveDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources);`
**this is the stacktrace:**
Caused by: org.apache.ibatis.executor.ExecutorException: Error preparing
statement. Cause:
org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException:
Table or view 'order_details' does not exist.
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:97)
at
org.apache.ibatis.executor.statement.RoutingStatementHandler.prepare(RoutingStatementHandler.java:59)
at
org.apache.ibatis.executor.ReuseExecutor.prepareStatement(ReuseExecutor.java:89)
at
org.apache.ibatis.executor.ReuseExecutor.doUpdate(ReuseExecutor.java:51)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at
org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy478.update(Unknown Source)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
... 167 common frames omitted
Caused by:
org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException:
Table or view 'order_details' does not exist.
at
org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.lambda$checkTableExists$3(SimpleTableSegmentBinder.java:130)
at
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:44)
at
org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.checkTableExists(SimpleTableSegmentBinder.java:127)
at
org.apache.shardingsphere.infra.binder.engine.segment.from.type.SimpleTableSegmentBinder.bind(SimpleTableSegmentBinder.java:84)
at
org.apache.shardingsphere.infra.binder.engine.statement.dml.InsertStatementBinder.lambda$bind$0(InsertStatementBinder.java:46)
at java.util.Optional.ifPresent(Optional.java:159)
at
org.apache.shardingsphere.infra.binder.engine.statement.dml.InsertStatementBinder.bind(InsertStatementBinder.java:46)
at
org.apache.shardingsphere.infra.binder.engine.type.DMLStatementBindEngine.bind(DMLStatementBindEngine.java:55)
at
org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bindSQLStatement(SQLBindEngine.java:63)
at
org.apache.shardingsphere.infra.binder.engine.SQLBindEngine.bind(SQLBindEngine.java:53)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:146)
at
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.<init>(ShardingSpherePreparedStatement.java:126)
at
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:126)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
at com.sun.proxy.$Proxy128.prepareStatement(Unknown Source)
at
org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:81)
at
org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
... 185 common frames omitted
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]