shijie-328931589 commented on issue #32280:
URL: 
https://github.com/apache/shardingsphere/issues/32280#issuecomment-2603504422

   The problem is getting worse on shardingshpere-jdbc 5.5.1。the sql "insert 
into TABLE(id,user_name) values (?,?) on conflict(id) do update set user_name = 
?" execute failed。
   exception:org.postgresql.util.PSQLException: 未设定参数值 3 的内容。
   
        at 
org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:275)
        at 
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:307)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:473)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:393)
        at 
org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
        at 
org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:153)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at 
org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114)
        at jdk.proxy2/jdk.proxy2.$Proxy31.execute(Unknown Source)
        at 
org.apache.shardingsphere.driver.executor.callback.execute.ExecuteCallbackFactory$1.executeSQL(ExecuteCallbackFactory.java:55)
        at 
org.apache.shardingsphere.driver.executor.callback.execute.ExecuteCallbackFactory$1.executeSQL(ExecuteCallbackFactory.java:51)
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:85)
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:64)
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:99)
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.parallelExecute(ExecutorEngine.java:95)
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:78)
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:66)
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:50)
        at 
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteExecutor.doExecute(DriverJDBCPushDownExecuteExecutor.java:102)
        at 
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteExecutor.lambda$execute$0(DriverJDBCPushDownExecuteExecutor.java:87)
        at 
org.apache.shardingsphere.driver.executor.engine.transaction.DriverTransactionalExecutor.execute(DriverTransactionalExecutor.java:56)
        at 
org.apache.shardingsphere.driver.executor.engine.pushdown.jdbc.DriverJDBCPushDownExecuteExecutor.execute(DriverJDBCPushDownExecuteExecutor.java:86)
        at 
org.apache.shardingsphere.driver.executor.engine.DriverExecuteExecutor.executePushDown(DriverExecuteExecutor.java:117)
        at 
org.apache.shardingsphere.driver.executor.engine.DriverExecuteExecutor.execute(DriverExecuteExecutor.java:105)
        at 
org.apache.shardingsphere.driver.executor.engine.facade.standard.StandardDriverExecutorFacade.execute(StandardDriverExecutorFacade.java:110)
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:248)
        at 
com.zhaopin.common3.datasource.dao.ReadwriteDAO.executeSql2(ReadwriteDAO.java:108)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
   
   
   my code is:
   
       public void executeSql1(String index) throws Exception {
           ShardingInfo currentShardingInfo = 
RoutingDataSourceUtils.getCurrentShardingInfo();
           ShardingSphereDataSource wrappedDataSource = 
(ShardingSphereDataSource)currentShardingInfo.getWrappedDataSource();
           try(Connection connection = wrappedDataSource.getConnection()){
               String sql = "insert into transactional_table(id,user_name) 
values (?,?) on conflict(id) do update set user_name = ?";
               PreparedStatement preparedStatement = 
connection.prepareStatement(sql);
               preparedStatement.setLong(1, 100L);
               preparedStatement.setString(2, "test");
               preparedStatement.setString(2, "test");
               preparedStatement.execute();
           }
       }


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