lmhmhl commented on pull request #9249:
URL: https://github.com/apache/shardingsphere/pull/9249#issuecomment-773729643


   @tristaZero 
   I have to say to there do exist some problems in my test, the datasource is 
created by `YamlShardingSphereDataSourceFactory` using yml file, in order to 
create two connections to different database instances to build different table 
structures, I separately get connections from `dataSourceMap` using database 
name. But the yml configuration are not work on these two sub connection, so I 
can only construct the sharding data all by myself, and the encrypt or replica 
query are not easy to test. Basically, I have to figure out why yml 
configuration are not work on sub connection fetched by `dataSourceMap`. Should 
I create two yml file or two datasources, and I have tried a lot but all 
failed, so this PR is  just a compromise, I am in confused now, I would be very 
glad if u can give me some advices. 
   ```java
       @Before
       public void initTable() {
           try {
               ShardingSphereConnection conn = dataSource.getConnection();
               Map<String, DataSource> dataSourceMap = conn.getDataSourceMap();
               Connection database0 = 
dataSourceMap.get("calcite_jdbc_0").getConnection();
               Connection database1 = 
dataSourceMap.get("calcite_jdbc_1").getConnection();
               RunScript.execute(database0, new 
InputStreamReader(Objects.requireNonNull(AbstractSQLTest.class.getClassLoader().getResourceAsStream("sql/calcite_data_0.sql"))));
               RunScript.execute(database1, new 
InputStreamReader(Objects.requireNonNull(AbstractSQLTest.class.getClassLoader().getResourceAsStream("sql/calcite_data_1.sql"))));
               conn.close();
           } catch (final SQLException ex) {
               throw new RuntimeException(ex);
           }
       }
   ```


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


Reply via email to