jlovej commented on issue #21874:
URL: 
https://github.com/apache/shardingsphere/issues/21874#issuecomment-1299822036

   > @jlovej You need to understand what each configuration you write means
   > 
   > <img alt="image" width="844" 
src="https://user-images.githubusercontent.com/5668787/199412874-05261578-b0a4-456d-a298-35cd11326022.png";>
   > 
   > 1. Logic table name should be the same with what in your SQL statement. 
(sys_shop_user)  
   > 2. Where is ds-${0..3}? You just configured `ds-0, ds-hla, ds-hlm, ds-ncl`
   > 3. ShardingAlgorithmName is a refference of one of `sharding-algorithms`, 
may be `database-tenant` or `database-default`.
   > 
   > Here is another example of `CLASS_BASED` sharding algorithm: 
https://github.com/apache/shardingsphere/blob/master/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-raw-jdbc-example/src/main/resources/META-INF/sharding-databases.yaml
   > 
   > If you still need help, please paste the text configuration, and think 
about how the person helping you will edit the picture.
   
   Sorry, the front two points have been dealt with. The screenshot has some 
problems and is misleading to you. I still don't understand the third point. 
But there is a new progress. I will only keep the 'actualDataNodes' 
configuration under' tables'. After removing all the others, after setting 
'DatabaseSharedingValue' in the business code, you can enter doSharing to 
confirm whether you need to set each table? In addition, setting 
'DatabaseShardingValue' needs to be coupled to business code. Besides using 
AOP, are there any other official solutions (with business code)?
   
   The configuration file is as follows:
   
   ```
   spring:
     shardingsphere:
       props:
         sql-show: true
       datasource:
         names: ds-0,ds-1,ds-2,ds-3
         ds-0:
           driver-class-name: com.mysql.cj.jdbc.Driver
           type: com.alibaba.druid.pool.DruidDataSource
           url: 
jdbc:mysql://127.0.0.1:3306/hl_workbench_master?useUnicode=true&characterEncoding=utf8&useOldAliasMetadataBehavior=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useInformationSchema=false&serverTimezone=UTC
           username: root
           password: abc123
         ds-1:
           driver-class-name: com.mysql.cj.jdbc.Driver
           type: com.alibaba.druid.pool.DruidDataSource
           url: 
jdbc:mysql://127.0.0.1:3306/hl_workbench_a?useUnicode=true&characterEncoding=utf8&useOldAliasMetadataBehavior=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useInformationSchema=false&serverTimezone=UTC
           username: root
           password: abc123
         ds-2:
           driver-class-name: com.mysql.cj.jdbc.Driver
           type: com.alibaba.druid.pool.DruidDataSource
           url: 
jdbc:mysql://127.0.0.1:3306/hl_workbench_b?useUnicode=true&characterEncoding=utf8&useOldAliasMetadataBehavior=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useInformationSchema=false&serverTimezone=UTC
           username: root
           password: abc123
         ds-3:
           driver-class-name: com.mysql.cj.jdbc.Driver
           type: com.alibaba.druid.pool.DruidDataSource
           url: 
jdbc:mysql://127.0.0.1:3306/hl_workbench_c?useUnicode=true&characterEncoding=utf8&useOldAliasMetadataBehavior=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useInformationSchema=false&serverTimezone=UTC
           username: root
           password: abc123
       rules:
         sharding:
           tables:
             sys_shop_user:
               actualDataNodes: ds-$->{0..3}.sys_shop_user
             shop:
               actualDataNodes: ds-$->{0..3}.shop
           shardingAlgorithms:
             database-tenant:
               type: CLASS_BASED
               props:
                 strategy: HINT
                 algorithmClassName: 
com.heilan.shop.workbench.common.algorithm.TenantDatabaseShardingAlgorithm
           defaultDatabaseStrategy:
             hint:
               sharding-algorithm-name: database-tenant
           defaultTableStrategy:
             none:
       enabled: true
   ```
   


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