You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "liruhui (via GitHub)" <gi...@apache.org> on 2023/04/01 04:04:28 UTC

[GitHub] [shardingsphere] liruhui commented on issue #24704: Vertical sharding how to code for java API

liruhui commented on issue #24704:
URL: https://github.com/apache/shardingsphere/issues/24704#issuecomment-1492822899

   @RaigorJiang  
   > 1. If the table already exists in a different DB, no configuration is required, and ShardingSphere can route correctly;
   > 2. If you want to execute CREATE TABLE through ShardingSphere, you can only set data nodes in the sharding table rule like the configuration you provided.
   
   ```
   vertical sharding database  not  need  any configuration   thit is OK  , 
   but  vertical sharding table no configuration is error 
   
   for example 
   
   one table has three column (id, name age) , ->vertical sharding table->  table_1 has column(id,name), table_2 has 
   colume(id,age)    columes named  "name" and “age” in different table   maybe table name is  different
   ``` 
   
   ```java
       public static void main(String[] args) throws Exception{
           Map<String, DataSource> mapDatasource = new HashMap<>();
           HikariDataSource table1Database = new HikariDataSource();
           table1Database.setDriverClassName();
           table1Database.setJdbcUrl();
           table1Database.setUsername();
           table1Database.setPassword();
   
           HikariDataSource table2Database = new HikariDataSource();
           table2Database.setDriverClassName();
           table2Database.setJdbcUrl();
           table2Database.setUsername();
           table2Database.setPassword();
           mapDatasource.put("table1Database",table1Database);
           mapDatasource.put("table2Database",table2Database);
   
           DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(mapDatasource, null, null);
           Connection connection = dataSource.getConnection();
           connection.prepareStatement("insert into table(id,name,age) values(1,'aaaa',22)").execute();
           connection.close();
       }
   ```
   
   ![image](https://user-images.githubusercontent.com/24687986/229264593-c13e6ee8-fc4a-4f79-8765-a34cb4251bca.png)
   
   
   ```
   I  think  this need configuraiton, but I not found API in RuleConfiration(Interface and implements class )   I do not know  how to config
   ```
   


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