XinShepherd opened a new issue, #24276:
URL: https://github.com/apache/shardingsphere/issues/24276

   # Bug Report
   Which version of ShardingSphere did you use?
   5.2.1
   
   ## Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ## H2 version
   ```
         <dependency>
           <groupId>com.h2database</groupId>
           <artifactId>h2</artifactId>
           <version>1.4.200</version>
         </dependency>
   ```
   ## Expected behavior
   H2 Dialect load table meta data successfully
   
   ## Actual behavior
   Dialect load table meta data error.
   
   the exception is:
   
   ```
   2023-02-21 15:25:38.864  INFO 9167 --- [           main] 
com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
   2023-02-21 15:25:38.867  INFO 9167 --- [           main] 
com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
   2023-02-21 15:27:14.538 ERROR 9167 --- [           main] 
a.s.i.m.d.s.l.SchemaMetaDataLoaderEngine : Dialect load table meta data error.
   
   java.sql.SQLException: Unknown exception: java.lang.NullPointerException
        at 
org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSphereSQLException.toSQLException(ShardingSphereSQLException.java:54)
 ~[shardingsphere-infra-util-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.schema.loader.SchemaMetaDataLoaderEngine.loadByDialect(SchemaMetaDataLoaderEngine.java:99)
 ~[shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.schema.loader.SchemaMetaDataLoaderEngine.load(SchemaMetaDataLoaderEngine.java:65)
 ~[shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.loadSchemas(GenericSchemaBuilder.java:95)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.build(GenericSchemaBuilder.java:78)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.schema.builder.GenericSchemaBuilder.build(GenericSchemaBuilder.java:66)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase.create(ShardingSphereDatabase.java:89)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.createGenericDatabases(ShardingSphereDatabasesFactory.java:81)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabasesFactory.create(ShardingSphereDatabasesFactory.java:69)
 [shardingsphere-infra-common-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:91)
 [shardingsphere-mode-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.mode.metadata.MetaDataContextsFactory.create(MetaDataContextsFactory.java:69)
 [shardingsphere-mode-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.mode.manager.standalone.StandaloneContextManagerBuilder.build(StandaloneContextManagerBuilder.java:49)
 [shardingsphere-standalone-mode-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.createContextManager(ShardingSphereDataSource.java:76)
 [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:64)
 [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:93)
 [shardingsphere-jdbc-core-5.2.1.jar:5.2.1]
   ```
   
   And then I debug the source code **H2SchemaMetaDataLoader.java** at line 
112, just like below
   
   
![image](https://user-images.githubusercontent.com/21291945/220283685-7cf668b3-8025-4fea-b0e6-28cab4f9bec6.png)
   
   ## Reason analyze (If you can)
   I have used the original datasource (not shardingDatasource) to init my 
tables in H2, and then **H2SchemaMetaDataLoader** will load the meta data from 
the datasource.
   
   From the screenshot,we can find that the **dataTypeMap** does not contains 
the dataType `'4'`, because the **dataTypeMap** is the TYPE_NAME to DATA_TYPE 
mappings, just like below
   
![image](https://user-images.githubusercontent.com/21291945/220288213-a4abb342-711c-4cd3-84b4-e094b015de55.png)
   
   ## Solution
   In my option, if we can directly use the value of dataType, and not get from 
**dataTypeMap** ?
   
   
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to