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

   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   5.2.0
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   insert success and return insert count 
   
   ### Actual behavior
   throw exception below:
   ```
   2022-10-15 15:58:55.484 ERROR 6488 --- [nio-8080-exec-2] 
o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet 
[dispatcherServlet] in context with path [] threw exception [Request processing 
failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
   ### Error updating database.  Cause: java.sql.SQLException: No value 
specified for parameter 2
   ### The error may exist in com/example/demo/dao/OrderDao.java (best guess)
   ### The error may involve 
com.example.demo.dao.OrderDao.insertWithSubStr-Inline
   ### The error occurred while setting parameters
   ### SQL: insert into t_order(order_id, order_name) values(?, subStr(?,1,3))
   ### Cause: java.sql.SQLException: No value specified for parameter 2
   ; bad SQL grammar []; nested exception is java.sql.SQLException: No value 
specified for parameter 2] with root cause
   
   java.sql.SQLException: No value specified for parameter 2
        at 
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) 
~[mysql-connector-java-8.0.22.jar:8.0.22]
        at 
com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) 
~[mysql-connector-java-8.0.22.jar:8.0.22]
        at 
com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
 ~[mysql-connector-java-8.0.22.jar:8.0.22]
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:396)
 ~[mysql-connector-java-8.0.22.jar:8.0.22]
        at 
com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:483)
 ~[druid-1.2.11.jar:1.2.11]
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$2.executeSQL(ShardingSpherePreparedStatement.java:439)
 ~[shardingsphere-jdbc-core-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement$2.executeSQL(ShardingSpherePreparedStatement.java:435)
 ~[shardingsphere-jdbc-core-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:95)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback.execute(JDBCExecutorCallback.java:75)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.syncExecute(ExecutorEngine.java:135)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.parallelExecute(ExecutorEngine.java:131)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.kernel.ExecutorEngine.execute(ExecutorEngine.java:116)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:65)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor.execute(JDBCExecutor.java:49)
 ~[shardingsphere-infra-executor-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.driver.executor.DriverJDBCExecutor.doExecute(DriverJDBCExecutor.java:156)
 ~[shardingsphere-jdbc-core-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.driver.executor.DriverJDBCExecutor.execute(DriverJDBCExecutor.java:145)
 ~[shardingsphere-jdbc-core-5.2.0.jar:5.2.0]
        at 
org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:402)
 ~[shardingsphere-jdbc-core-5.2.0.jar:5.2.0]
        at 
org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
 ~[mybatis-3.5.6.jar:3.5.6]
        at 
org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
 ~[mybatis-3.5.6.jar:3.5.6]
        at 
com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doUpdate(MybatisSimpleExecutor.java:56)
 ~[mybatis-plus-core-3.4.2.jar:3.4.2]
        at 
org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) 
~[mybatis-3.5.6.jar:3.5.6]
        at 
com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.update(MybatisCachingExecutor.java:85)
 ~[mybatis-plus-core-3.4.2.jar:3.4.2]
        at 
org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
 ~[mybatis-3.5.6.jar:3.5.6]
        at 
org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
 ~[mybatis-3.5.6.jar:3.5.6]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[na:1.8.0_201]
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[na:1.8.0_201]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0_201]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
        at 
org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
 ~[mybatis-spring-2.0.5.jar:2.0.5]
        at com.sun.proxy.$Proxy61.insert(Unknown Source) ~[na:na]
        at 
org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:271) 
~[mybatis-spring-2.0.5.jar:2.0.5]
        at 
com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:60)
 ~[mybatis-plus-core-3.4.2.jar:3.4.2]
        at 
com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
 ~[mybatis-plus-core-3.4.2.jar:3.4.2]
        at 
com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
 ~[mybatis-plus-core-3.4.2.jar:3.4.2]
        at com.sun.proxy.$Proxy65.insertWithSubStr(Unknown Source) ~[na:na]
        at 
com.example.demo.rest.OrderController.orderNew(OrderController.java:27) 
~[classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
~[na:1.8.0_201]
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
~[na:1.8.0_201]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[na:1.8.0_201]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
        at 
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) 
~[tomcat-embed-core-9.0.41.jar:4.0.FR]
        at 
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
 ~[spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) 
~[tomcat-embed-core-9.0.41.jar:4.0.FR]
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 
~[tomcat-embed-websocket-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
 ~[spring-web-5.2.12.RELEASE.jar:5.2.12.RELEASE]
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
 ~[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) 
[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 
[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) 
[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) 
[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
[tomcat-embed-core-9.0.41.jar:9.0.41]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[na:1.8.0_201]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[na:1.8.0_201]
        at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 [tomcat-embed-core-9.0.41.jar:9.0.41]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]
   
   ```
   
   ### Reason analyze (If you can)
   ShardingSphere-JDBC doesn't handle parameters in sql function well, maybe.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   ```
     @Insert("insert into t_order(order_id, order_name) values(#{orderId}, 
subStr(#{orderName},1,3))")
     int insertWithSubStr(@Param("orderId") int orderId, @Param("orderName") 
String orderName);
   ```
   
   ### Example codes for reproduce this issue (such as a github link).
   
[https://github.com/CatInRl/sharding-jdbc-demo](https://github.com/CatInRl/sharding-jdbc-demo)
   `curl "127.0.0.1:8080/order/new?orderName=order1&orderId=1"`
   


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