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

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   
   
   ### Which version of ShardingSphere did you use?
   5.2.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
           <dependency>
               <groupId>org.apache.shardingsphere</groupId>
               
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
               <version>5.2.1</version>
           </dependency>
   
   ### Expected behavior
   
   Added successfully
   
   ### Actual behavior
   Failed to add
   
   ### Reason analyze (If you can)
   
   An error occurred while injecting parameters using # {} ; uncategorized 
SQLException; SQL state [99999]; error code [17041]; 索引中丢失  IN 或 OUT 参数:: 1; 
nested exception is java.sql.SQLException: 索引中丢失  IN 或 OUT 参数:: 1
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   My SQL statement 
   
   ` INSERT INTO aim_data_middle(id,
                                       product_no,
                                       paper_no,
                                       total_result_status,
                                       measure_time,
                                       work_day,
                                       ip,
                                       measure_data_singlelayer,
                                       pkid,
                                       creater,
                                       creat_time,
                                       editer,
                                       edit_time,
                                       measure_type)
           select id,
                  product_no,
                  paper_no,
                  total_result_status,
                  measure_time,
                  work_day,
                  ip,
                  measure_data_singlelayer,
                  pkid,
                  creater,
                  creat_time,
                  editer,
                  edit_time,
                  measure_type
           from AIM_DATA_MEASURE t
           where t.product_no = #{id}`
   
   
   
   my rule  
   
   
     @Primary
       @Bean("dataSource2")
       public DataSource dataSource2() throws SQLException {
           //数据源Map
           Map<String, DataSource> dsMap = new HashMap<>();
           //配置主库
           DruidDataSource masterDs = new DruidDataSource();
           masterDs.setDriverClassName("oracle.jdbc.OracleDriver");
           masterDs.setUrl(masterJdbcUrl);
           masterDs.setUsername(masterUsername);
           masterDs.setPassword(masterPassword);
           dsMap.put("master_ds", masterDs);
           //配置读库1
           DruidDataSource replicaDs1 = new DruidDataSource();
           replicaDs1.setDriverClassName("oracle.jdbc.OracleDriver");
           replicaDs1.setUrl(replica1JdbcUrl);
           replicaDs1.setUsername(replica1Username);
           replicaDs1.setPassword(replica1Password);
           dsMap.put("replica_ds_1", replicaDs1);
   
   
   
           ArrayList<String> arrayList=new ArrayList<>();
           arrayList.add("replica_ds_1");
           //主从数据源配置
           List<ReadwriteSplittingDataSourceRuleConfiguration> dsConfig = new 
ArrayList<>();
           dsConfig.add(new ReadwriteSplittingDataSourceRuleConfiguration("ds",
                   new 
StaticReadwriteSplittingStrategyConfiguration("master_ds",arrayList),
                   null, "load_balancer"));
           //负载均衡算法配置
           Map<String, AlgorithmConfiguration> loadBalanceMap = new HashMap<>();
           loadBalanceMap.put("load_balancer", new 
AlgorithmConfiguration("ROUND_ROBIN", new Properties()));
           List<RuleConfiguration> listRule=new ArrayList<>();
           SQLTranslatorRuleConfiguration sqlTranslatorRuleConfig =new 
SQLTranslatorRuleConfiguration("Native", false);
           CacheOption cacheOption = new CacheOption(128,1024);
           SQLParserRuleConfiguration sqlParserRuleConfiguration = new 
SQLParserRuleConfiguration(true,cacheOption,cacheOption);
           ReadwriteSplittingRuleConfiguration ruleConfig = new 
ReadwriteSplittingRuleConfiguration(dsConfig, loadBalanceMap);
           listRule.add(ruleConfig);
           listRule.add(sqlTranslatorRuleConfig);
           listRule.add(sqlParserRuleConfiguration);
           Properties props = new Properties();
           props.setProperty("sql-show", "true"); // ← 开启 SQL 打印
           props.setProperty("check-table-metadata-enabled", "false"); // ← 
修复关键点
   //        props.setProperty("sqlCommentParseEnabled", "false"); // ← 修复关键点
   //        props.setProperty("useOriginalSQLWhenTranslatingFailed", "true"); 
// ← 修复关键点
           log.info("创建 ShardingSphere 读写分离数据源");
           return ShardingSphereDataSourceFactory.createDataSource(dsMap, 
listRule,props);
       }
   
   My Oracle version
   
   
        <dependency>
               <groupId>com.oracle.database.jdbc</groupId>
               <artifactId>ojdbc8</artifactId>
               <version>19.3.0.0</version>
               <scope>runtime</scope>
           </dependency>
   
   
   
   
   
   This is my data configuration file. Originally, OracleDataSource was the 
default data source, but now my default data source is DataSource2, and its 
master.ds is actually OracleDataSource
   
   Adding failed while using datasouce2 as the default data source
   
   
   Error Msg :
    uncategorized SQLException; SQL state [99999]; error code [17041]; 索引中丢失  
IN 或 OUT 参数:: 1; nested exception is java.sql.SQLException: 索引中丢失  IN 或 OUT 
参数:: 1
   
   
   
   I added it successfully without using datasouce2 as the default data source
   
   
   Please help me, everyone!!!!
   
   
[DataSourceConfig.java](https://github.com/user-attachments/files/24833625/DataSourceConfig.java)
   


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