homeway88 commented on issue #15160:
URL: 
https://github.com/apache/shardingsphere/issues/15160#issuecomment-1028857477


   > @homeway88 I guess you executed the create table statement on the native 
database after starting the JDBC program, so that JDBC cannot perceive the 
newly added table.
   > 
   > There are two ways to solve this problem, write the code to create the 
table through JDBC, so that the newly added table can be loaded into the 
metadata. A better way is to use both JDBC and Proxy through the Mode feature. 
Proxy is responsible for managing configuration and DDL operations, and JDBC 
reads these configurations through Mode.
   
   I figured out the reason of this case is because missing table metadata of 
newly created table. So I solve this problem with  these two steps:
   * first , use sharding JDBC to create real tables. so I change ddl sql into 
this:
   ```sql
   create table if not exists person (
       id   bigint primary key,
       name varchar(32),
       age int
   );
   ```
   * second, change h2 database to mysql mode. So the meta data of the table 
can be loaded.
   ```properties
   # datasource connection config
   spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:h2:mem:test;MODE=MYSQL
   ```
   
   


-- 
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-unsubscr...@shardingsphere.apache.org

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


Reply via email to