Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cause: org.apache.shardingsphere.infra.exception.TableNotExistsException: Table or view *** does not exist. #29569

Open
prefect1005 opened this issue Dec 27, 2023 · 12 comments

Comments

@prefect1005
Copy link

prefect1005 commented Dec 27, 2023

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.

@RaigorJiang
Copy link
Contributor

@prefect1005 So did you configured database db2 and create (or load) table2 in it?

@prefect1005
Copy link
Author

@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
Copy link
Contributor

RaigorJiang commented Dec 28, 2023

@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.

@prefect1005
Copy link
Author

@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.

@prefect1005
Copy link
Author

image
i try to config like this, but it not used

@RaigorJiang
Copy link
Contributor

@prefect1005
OK, so you just want to access tables in multiple data sources, not multiple logic data bases.
let's do two things:

  1. Configure single rule *.*; (link)
  2. 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.

@prefect1005
Copy link
Author

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'?

@6z7
Copy link

6z7 commented Jan 10, 2024

+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, 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'?

@vaqsummer
Copy link

@prefect1005 @6z7
It is possible that duplicate beanName for multiple datasources causes the datasource to not load,like db2 is used db1 datasource。

Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label Feb 11, 2024
@strongduanmu
Copy link
Member

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.

@github-actions github-actions bot removed the stale label Mar 12, 2024
Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.

@github-actions github-actions bot added the stale label Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants