You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/27 04:04:48 UTC

[GitHub] [shardingsphere] myflx commented on issue #10419: shardingjdbc5.0+springboot+oracle:start occured a error 'table or view does not exist',username is dirrerent with table schema

myflx commented on issue #10419:
URL: https://github.com/apache/shardingsphere/issues/10419#issuecomment-927509499


   mysql dialect has same question in version v4.1.1 when using shadow datasource and there are more than one tables in other database i find schema lost when debug. exception below:
   ````java
   Caused by: java.sql.SQLSyntaxErrorException: Unknown table '{other table in other database}' in information_schema
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
   	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
   	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
   	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)
   	at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
   	at com.mysql.cj.jdbc.DatabaseMetaData$7.forEach(DatabaseMetaData.java:3182)
   	at com.mysql.cj.jdbc.DatabaseMetaData$7.forEach(DatabaseMetaData.java:3170)
   	at com.mysql.cj.jdbc.IterateBlock.doForAll(IterateBlock.java:50)
   	at com.mysql.cj.jdbc.DatabaseMetaData.getPrimaryKeys(DatabaseMetaData.java:3223)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.metadata.MultipleDatabaseMetaData.getPrimaryKeys(MultipleDatabaseMetaData.java:142)
   	at org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaDataLoader.loadPrimaryKeys(ColumnMetaDataLoader.java:115)
   	at org.apache.shardingsphere.sql.parser.binder.metadata.column.ColumnMetaDataLoader.load(ColumnMetaDataLoader.java:60)
   	at org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaDataLoader.load(SchemaMetaDataLoader.java:84)
   	at org.apache.shardingsphere.sql.parser.binder.metadata.schema.SchemaMetaDataLoader.load(SchemaMetaDataLoader.java:76)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.context.ShadowRuntimeContext.loadSchemaMetaData(ShadowRuntimeContext.java:69)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.context.SingleDataSourceRuntimeContext.createMetaData(SingleDataSourceRuntimeContext.java:56)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.context.SingleDataSourceRuntimeContext.<init>(SingleDataSourceRuntimeContext.java:50)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.context.ShadowRuntimeContext.<init>(ShadowRuntimeContext.java:48)
   	at org.apache.shardingsphere.shardingjdbc.jdbc.core.datasource.ShadowDataSource.<init>(ShadowDataSource.java:46)
   	at org.apache.shardingsphere.shardingjdbc.api.ShadowDataSourceFactory.createDataSource(ShadowDataSourceFactory.java:66)
   	at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration.shadowDataSource(SpringBootConfiguration.java:139)
   	at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$4a3fbefa.CGLIB$shadowDataSource$4(<generated>)
   	at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$4a3fbefa$$FastClassBySpringCGLIB$$210ceb83.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
   	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
   	at org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration$$EnhancerBySpringCGLIB$$4a3fbefa.shadowDataSource(<generated>)
   	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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
   
   ```
   
   
   this step `loadAllTableNames` load all table of all database
   ```java
   
   public static SchemaMetaData load(final DataSource dataSource, final int maxConnectionCount, final String databaseType) throws SQLException {
           List<String> tableNames;
           try (Connection connection = dataSource.getConnection()) {
               tableNames = loadAllTableNames(connection, databaseType);
           }
           log.info("Loading {} tables' meta data.", tableNames.size());
           if (0 == tableNames.size()) {
               return new SchemaMetaData(Collections.emptyMap());
           }
           List<List<String>> tableGroups = Lists.partition(tableNames, Math.max(tableNames.size() / maxConnectionCount, 1));
           Map<String, TableMetaData> tableMetaDataMap = 1 == tableGroups.size()
                   ? load(dataSource.getConnection(), tableGroups.get(0), databaseType) : asyncLoad(dataSource, maxConnectionCount, tableNames, tableGroups, databaseType);
           return new SchemaMetaData(tableMetaDataMap);
       }
   
   ```
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org