Cause: org.apache.shardingsphere.infra.exception.TableNotExistsException: Table or view `***` does not exist.
use 5.4.1
config ` mode: type: Standalone
databaseName: db1`
sql1: "select * from db1.table" sql2:"select * form db2.table2"
sql1 no problem
but db2.table2 will TableNotExistsException
Caused by: org.apache.shardingsphere.infra.exception.TableNotExistsException: Table or view table2 does not exist.
@prefect1005 So did you configured database db2 and create (or load) table2 in it?
@RaigorJiang Of course . in other word, if one project need to select db1 and db2 database, just db1.table1 need sharding config,so how to config that we can execute db2`s sql correcttly
@RaigorJiang Of course . in other word, if one project need to select db1 and db2 database, just db1.table1 need sharding config,so how to config that we can execute db2`s sql correcttly
Create two logic databases, named db1 and db2.
@RaigorJiang im sorry that i used "ShardingSphere-JDBC", and i dont know how to create logic databases, can you give me one demo or config file ? thank you.
i try to config like this, but it not used
@prefect1005 OK, so you just want to access tables in multiple data sources, not multiple logic data bases. let's do two things:
- Configure single rule
*.*; (link) - Use table name directly when executing SQL (select * from table2)
Note that this only applies to the case where there are no tables with the same name in data source 1 and data source 2.
well, i got it.
in my project, every sql has point db, like 'select * from db1.table1'
in this case, its not work until i config 'databaseName:db1' lets coding not used default databaseName - 'logic_db'
and then, other sql 'select * from db2.table2' will execute wrong because that dbMap not containskey 'db2'.
so it well success after i delete all point database(and config db1/db2 datasource both, eventhough all database in the same entity database(same ip and port)).
but in this way, the code will confusion because i can`t recognize the table from which db directtly .
finally, Is there a plan to support the SQL that point db like 'select * from db3.table3'?
+1 ,this scenario is very common.
well, i got it. in my project, every sql has point db, like 'select * from db1.table1' in this case, it
s not work until i config 'databaseName:db1' lets coding not used default databaseName - 'logic_db' and then, other sql 'select * from db2.table2' will execute wrong because that dbMap not containskey 'db2'. so it well success after i delete all point database(and config db1/db2 datasource both, eventhough all database in the same entity database(same ip and port)). but in this way, the code will confusion because i can`t recognize the table from which db directtly . finally, Is there a plan to support the SQL that point db like 'select * from db3.table3'?
@prefect1005 @6z7 It is possible that duplicate beanName for multiple datasources causes the datasource to not load,like db2 is used db1 datasource。
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
I think you can try hybrid-architecture - https://shardingsphere.apache.org/document/current/en/overview/#hybrid-architecture. You can use Proxy to manage, create multiple logical databases, and then JDBC to access these logical databases.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.