liruhui commented on issue #25078: URL: https://github.com/apache/shardingsphere/issues/25078#issuecomment-1506473966
@RaigorJiang **OK I Re-describe the requirement** ## 1. tables  ## 2.dependency ```xml <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.25</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.shardingsphere/shardingsphere-jdbc-core --> <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>shardingsphere-jdbc-core</artifactId> <version>5.3.1</version> </dependency> </dependencies> ``` ## 3. javaCode ```java public static void main(String[] args) throws Exception { Map<String, DataSource> mapDatasource = new HashMap<>(); HikariDataSource table1Database = new HikariDataSource(); table1Database.setDriverClassName(Driver.class.getName()); table1Database.setJdbcUrl("jdbc:mysql://localhost:3306/sharding1?serverTimezone=UTC"); table1Database.setUsername("root"); table1Database.setPassword("rootroot"); HikariDataSource table2Database = new HikariDataSource(); table2Database.setDriverClassName(Driver.class.getName()); table2Database.setJdbcUrl("jdbc:mysql://localhost:3306/sharding2?serverTimezone=UTC"); table2Database.setUsername("root"); table2Database.setPassword("rootroot"); mapDatasource.put("table1Database",table1Database); mapDatasource.put("table2Database",table2Database); DataSource dataSource = ShardingSphereDataSourceFactory.createDataSource(mapDatasource, null, null); Connection connection = dataSource.getConnection(); connection.prepareStatement("insert into t_user(id,name,age) values(1,'aaaa',22)").execute(); connection.close(); } ``` ## myquestion ``` SQL in javacode execute error because id,name, age in different table, I want to know how to config SQL can execute successful and data can insert different table successful. ``` -- 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]
