You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/11/23 08:55:24 UTC

[GitHub] [shardingsphere] fyname opened a new issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

fyname opened a new issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754


   Which version of ShardingSphere did you use?
   version: 5.0.0
   
   Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   use: ShardingSphere-JDBC
   
   Expected behavior
   Actual behavior
   Reason analyze (If you can)
   
   Custom SPI not called found
   The shardingwehre interface is not introduced, the call is normal, and the data is saved to MySQL
   The SQL exception occurred in the configuration after reference is as follows:
   
   error:
   
   2021-11-23 16:52:11.495  INFO 5992 --- [           main] c.f.s.multitenancy.OrderSpringBootTests  : Started OrderSpringBootTests in 8.84 seconds (JVM running for 11.281)
   OrderDAOImpl+save:{"id":1,"merchant":"taobao","order_no":"1637657531869000001","order_time":1637657531869,"user_id":1}
   
   org.springframework.dao.TransientDataAccessResourceException: 
   ### Error updating database.  Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
   ### The error may exist in file [E:\workspace\multit-tenant\target\classes\com\freesun\shardingsphere\multitenancy\dao\OrderMapper.xml]
   ### The error may involve com.freesun.shardingsphere.multitenancy.dao.OrderDAO.save-Inline
   ### The error occurred while setting parameters
   ### SQL: insert into tb_order         (             `user_id`,             `order_no`,             `order_time`,             `merchant`         )         values         (             ?,             ?,             ?,             ?         )
   ### Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
   ; Parameter index out of range (1 > number of parameters, which is 0).; nested exception is java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
   
   	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:110)
   	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
   	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79)
   	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79)
   	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
   	at com.sun.proxy.$Proxy203.insert(Unknown Source)
   	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271)
   	at com.freesun.shardingsphere.multitenancy.dao.OrderDAOImpl.save(OrderDAOImpl.java:20)
   	at com.freesun.shardingsphere.multitenancy.dao.OrderDAOImpl$$FastClassBySpringCGLIB$$4237c205.invoke(<generated>)
   	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
   	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
   	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
   	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
   	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
   	at com.freesun.shardingsphere.multitenancy.dao.OrderDAOImpl$$EnhancerBySpringCGLIB$$15aa4ea9.save(<generated>)
   	at com.freesun.shardingsphere.multitenancy.service.impl.OrderServiceImpl.save(OrderServiceImpl.java:17)
   	at com.freesun.shardingsphere.multitenancy.OrderSpringBootTests.save(OrderSpringBootTests.java:45)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
   	at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
   	at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
   	at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
   	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
   	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
   	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
   	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
   Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
   	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.checkBounds(ClientPreparedStatement.java:1396)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.getCoreParameterIndex(ClientPreparedStatement.java:1409)
   	at com.mysql.cj.jdbc.ClientPreparedStatement.setObject(ClientPreparedStatement.java:1693)
   	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.setObject(HikariProxyPreparedStatement.java)
   	at org.apache.shardingsphere.driver.jdbc.adapter.AbstractPreparedStatementAdapter.lambda$addParameters$0(AbstractPreparedStatementAdapter.java:289)
   	at org.apache.shardingsphere.driver.jdbc.adapter.AbstractPreparedStatementAdapter.replaySetParameter(AbstractPreparedStatementAdapter.java:281)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.replaySetParameter(ShardingSpherePreparedStatement.java:415)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.replay(ShardingSpherePreparedStatement.java:407)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.cacheStatements(ShardingSpherePreparedStatement.java:403)
   	at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:297)
   	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
   	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
   	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
   	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
   	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
   	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
   	... 45 more
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fyname removed a comment on issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
fyname removed a comment on issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754#issuecomment-978723519


   thanks  config update success


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754#issuecomment-977660701


   @fyname 
   
   
   ```
       rules:
         sharding:
           tables:
             t_order:
               actualDataNodes: tmall.tb_order,taobao.tb_order,aliyun.tb_order
               keyGenerateStrategy:
                 column: order_id
                 keyGeneratorName: snowflake
           defaultDatabaseStrategy:
             standard:
               shardingColumn: merchant
               shardingAlgorithmName: db-classbased
           defaultTableStrategy:
             none:
   ```
   
   `change to:`
   
   ```
       rules:
         sharding:
           tables:
             tb_order:
               actualDataNodes: tmall.tb_order,taobao.tb_order,aliyun.tb_order
               keyGenerateStrategy:
                 column: order_id
                 keyGeneratorName: snowflake
           defaultDatabaseStrategy:
             standard:
               shardingColumn: merchant
               shardingAlgorithmName: db-classbased
           defaultTableStrategy:
             none:
   ```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754#issuecomment-976532527


   @fyname Hi, Let 's me check it.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fyname closed issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
fyname closed issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fyname commented on issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
fyname commented on issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754#issuecomment-978723519


   thanks  config update success


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] fyname commented on issue #13754: updating database. Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

Posted by GitBox <gi...@apache.org>.
fyname commented on issue #13754:
URL: https://github.com/apache/shardingsphere/issues/13754#issuecomment-978723651


   thanks config update success


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org