yangbiyao opened a new issue, #30599:
URL: https://github.com/apache/shardingsphere/issues/30599

   ## Question
   my db setting:
   spring:
     redis:
       host: 192.168.19.227
       database: 11
       port: 26379
       password: 123456
       timeout: 45000
     datasource:
       dynamic:
         primary: master
         datasource:
           master:
             type: com.zaxxer.hikari.HikariDataSource
             driver-class-name: com.mysql.cj.jdbc.Driver
             url: 
jdbc:mysql://192.168.19.246:3306/test_base?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
             username: root
             password: zpXtGT%jO5fB
           sharding:
             url: jdbc:shardingsphere:classpath:sharding-dev.yaml
             driver-class-name: 
org.apache.shardingsphere.driver.ShardingSphereDriver
   
   
   I add this setting in sharding-dev.yaml:
   `mode:
     type: Standalone
     repository:
       type: JDBC
   dataSources:
     ds_1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       url: 
jdbc:mysql://192.168.19.246:3306/test_sharding_1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true
       username: root
       password: zpXtGT%jO5fB
     ds_2:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       url: 
jdbc:mysql://192.168.19.246:3306/test_sharding_2?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true
       username: root
       password: zpXtGT%jO5fB
     ds_3:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       url: 
jdbc:mysql://192.168.19.246:3306/test_sharding_3?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true
       username: root
       password: zpXtGT%jO5fB
     ds_4:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       url: 
jdbc:mysql://192.168.19.246:3306/test_sharding_4?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true
       username: root
       password: zpXtGT%jO5fB
   rules:
     - !SHARDING
       tables:
         sharding_two:
           actualDataNodes: 
ds_$->{1..4}.sharding_two_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
         sharding_two_item:
           actualDataNodes: 
ds_$->{1..4}.sharding_two_item_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
         eqs_redundance:
           actualDataNodes: 
ds_$->{1..4}.eqs_redundance_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
         eqs_redundance2:
           actualDataNodes: 
ds_$->{1..4}.eqs_redundance2_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
         eqs_main_data_table:
           actualDataNodes: 
ds_$->{1..4}.eqs_main_data_table_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
         eqs_main_data_table2:
           actualDataNodes: 
ds_$->{1..4}.eqs_main_data_table2_$->{com.crcc19.sharding.common.utils.CommonUtil.getActualDataNodes()}
           tableStrategy:
             standard:
               shardingColumn: company_code
               shardingAlgorithmName: common_sharding
       bindingTables:
         - sharding_two,sharding_two_item
       #  defaultShardingColumn: id
       defaultDatabaseStrategy:
         standard:
           shardingColumn: company_code
           shardingAlgorithmName: database_sharding
       defaultTableStrategy:
         none:
   
       shardingAlgorithms:
         database_sharding:
           type: CLASS_BASED
           props:
             strategy: STANDARD
             algorithmClassName: 
com.crcc19.sharding.common.sharding.DatabaseShardingAlgorithm
         common_sharding:
           type: CLASS_BASED
           props:
             strategy: STANDARD
             algorithmClassName: 
com.crcc19.sharding.common.sharding.CommonShardingAlgorithm
   
     - !BROADCAST
       tables:
         - eqs_dict
   transaction:
     defaultType: XA
     providerType: Atomikos
   props:
     sql-show: true`
   
   in my code like this:
   `    @Transactional
       @Override
       public Boolean save(EqsDictDto eqsDictDto) {
   
   //           Integer integer = ThreadLocalUtil.getInteger();
   //           log.info("{}", integer);
   //           log.info("{}",ThreadLocalUtil.get());
           EqsDict bean = BeanUtil.toBean(eqsDictDto, EqsDict.class);
   //           bean.setUpdateTimes(++integer);
   
           return this.baseMapper.insert(bean) > 0;
       }`
   
   i set one of the eqs_dict tables's property of  "update_time " column not 
null, and add a data with a null value "update time" by save method.
   The other three tables save successfully without rollback. and Log as 
follows:
   `
   2024-03-22 10:00:21.157  WARN 25168 --- [nio-6003-exec-1] 
c.a.icatch.jta.TransactionManagerImp     : This method needs a transaction for 
the calling thread and none exists.
   Possible causes: either you didn't start a transaction,
   it rolledback due to timeout, or it was committed already.
   ACTIONS: You can try one of the following: 
   1. Make sure you started a transaction for the thread.
   2. Make sure you didn't terminate it yet.
   3. Increase the transaction timeout to avoid automatic rollback of long 
transactions;
      check http://www.atomikos.com/Documentation/JtaProperties for how to do 
this.
   
   org.springframework.dao.DataIntegrityViolationException: 
   ### Error updating database.  Cause: java.sql.SQLException: Field 
'update_time' doesn't have a default value
   ### The error may exist in 
com/crcc19/sharding/common/mapper/EqsDictMapper.java (best guess)
   ### The error may involve 
com.crcc19.sharding.common.mapper.EqsDictMapper.insert-Inline
   ### The error occurred while setting parameters
   ### SQL: INSERT INTO eqs_dict  ( id, dict_type, label, value, is_default, 
remarks, sort_order )  VALUES (  ?, ?, ?, ?, ?, ?, ?  )
   ### Cause: java.sql.SQLException: Field 'update_time' doesn't have a default 
value`
   I make sure the databases are up and running. and four dbsource come from 
one same mysql instance.
   Nothing in the xa_tx.log file. how to make it work?
   


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