Open Pik1031 opened 1 year ago
If you want to access actual table, you should use /* SHARDINGSPHERE_HINT: DATA_SOURCE_NAME=ds_0 */ SELECT * FROM t_order;
to pass sql to some datasource. For more details, you can refer - https://shardingsphere.apache.org/document/current/en/user-manual/common-config/sql-hint/#datasource-pass-through
If you want to access actual table, you should use
/* SHARDINGSPHERE_HINT: DATA_SOURCE_NAME=ds_0 */ SELECT * FROM t_order;
to pass sql to some datasource. For more details, you can refer - https://shardingsphere.apache.org/document/current/en/user-manual/common-config/sql-hint/#datasource-pass-through Thanks for the answer, but it didn't work.
`dataSources: backup: dataSourceClassName: xxxx driverClassName: xxx url: xxxx username: xxx password: xx filters: stat initialSize: 5 minIdle: 3 maxActive: 60 maxWait: 60000 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis : 300000 validationQuery: SELECT 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 removeAbandoned: true removeAbandonedTimeout: 200 validationQueryTimeout: 200 logAbandoned: true
rules:
!SINGLE tables: backup.* defaultDataSource: backup !SHARDING tables: t_user: actualDataNodes : backup.tuser$->{1..19} tableStrategy: hint: shardingAlgorithmName: hint_rule shardingAlgorithms: hint_rule: type: HINT_SHARD props: sql-show: true ` this is my yaml
same error here. I'm learn about latest shardingsphere-jdbc and do some test follow tutorial can't get running
uncategorized SQLException; SQL state [HY000]; error code [30000]; Unknown exception: null
read document from t_order
config.yml
mode:
type: Standalone
repository:
type: JDBC
schemaName: SCOTT
dataSources:
ds_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: oracle.jdbc.OracleDriver
jdbcUrl: jdbc:oracle:thin:@//127.0.0.1:1521/orcl
username: scott
password: 123456
rules:
- !SINGLE
tables:
- "*.*"
defaultDataSource: db_0
- !SHARDING
tables:
t_order:
actualDataNodes: ds_0.t_order_$->{0..1}
tableStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: t_order_inline
bindingTables:
- t_order
defaultDatabaseStrategy:
standard:
shardingColumn: id
shardingAlgorithmName: database_inline
defaultTableStrategy:
none:
shardingAlgorithms:
database_inline:
type: INLINE
props:
algorithm-expression: ds_0->{id % 2}
t_order_inline:
type: INLINE
props:
algorithm-expression: t_order_$->{id % 2}
props:
sql-show: true
application.yml
spring:
datasource:
driver-class-name: org.apache.shardingsphere.driver.ShardingSphereDriver
url: jdbc:shardingsphere:classpath:config.yml
main:
banner-mode: off
mybatis:
type-aliases-package: com.f.sharedingjdbc.domain
mapper-locations: classpath:mapper/*.xml
logging:
level:
com.f.sharedingjdbc.mapper: debug
order table sql xml file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.f.sharedingjdbc.mapper.OrderMapper">
<select id="list" resultType="com.f.sharedingjdbc.domain.TOrder">
SELECT * FROM t_order
</select>
</mapper>
database have three table used for test query
I'm found problem, oracle needs change table uppercase for me situation😂
Question
For English only, other languages will not accept.
Before asking a question, make sure you have:
When I run a SQL statement to access the actual table, the following error occurs:
Sharding -jdbc 5.40 `org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script from resource [class path resource [init.sql]]; nested exception is org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException
Caused by: org.apache.shardingsphere.dialect.exception.syntax.table.NoSuchTableException at org.apache.shardingsphere.sharding.route.engine.condition.engine.InsertClauseShardingConditionEngine.lambda$appendMissingShardingConditions$1(InsertClauseShardingConditionEngine.java:97) at org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:41) at org.apache.shardingsphere.sharding.route.engine.condition.engine.InsertClauseShardingConditionEngine.appendMissingShardingConditions(InsertClauseShardingConditionEngine.java:97) at org.apache.shardingsphere.sharding.route.engine.condition.engine.InsertClauseShardingConditionEngine.createShardingConditionsWithInsertValues(InsertClauseShardingConditionEngine.java:89) at org.apache.shardingsphere.sharding.route.engine.condition.engine.InsertClauseShardingConditionEngine.createShardingConditions(InsertClauseShardingConditionEngine.java:74) at org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngine.createShardingConditions(ShardingConditionEngine.java:53) at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createShardingConditions(ShardingSQLRouter.java:80) at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext0(ShardingSQLRouter.java:65) at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:59) at org.apache.shardingsphere.sharding.route.engine.ShardingSQLRouter.createRouteContext(ShardingSQLRouter.java:47) at org.apache.shardingsphere.infra.route.engine.impl.PartialSQLRouteExecutor.route(PartialSQLRouteExecutor.java:69) at org.apache.shardingsphere.infra.route.engine.SQLRouteEngine.route(SQLRouteEngine.java:57) at org.apache.shardingsphere.infra.connection.kernel.KernelProcessor.route(KernelProcessor.java:60) at org.apache.shardingsphere.infra.connection.kernel.KernelProcessor.generateExecutionContext(KernelProcessor.java:51) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.createExecutionContext(ShardingSphereStatement.java:510) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute0(ShardingSphereStatement.java:441) at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement.execute(ShardingSphereStatement.java:376) at org.springframework.jdbc.datasource.init.ScriptUtils.executeSqlScript(ScriptUtils.java:260) ... 37 more
`
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.
why?and how?