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/05/24 08:46:02 UTC

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

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


   > @PaleWhiteDot @chenxk I have tried to reproduce this problem, but failed. Can you provide steps to reproduce this exception?
   
   I found  where the question is? In this method:PhysicalIndexMetaDataLoader.load(final Connection connection, final String table), will invoke connection.getSchema() and then will invoke the instance MetaDataConnectionAdapter.getSchema()
   ```
   public String getSchema() {
           return DatabaseMetaDataDialectHandlerFactory.findHandler(databaseType).map(handler -> handler.getSchema(connection)).orElse(getSchema(connection));
       }
   ```
   handle.getSchema(connection) like this(in this method OracleDatabaseMetaDataDialectHandler.getSchema())
   ```
   @Override
       public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }
   ```
   The code try to get my username as the schema, undoubted it is impossible be null,so this place
   ```
   handler.getSchema(connection)).orElse(getSchema(connection))
   ```
   won't invoke orElse logic.But If invoke orElse i will get the correct schema


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

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