You have an error in your SQL syntax;

You have an error in your SQL syntax;

2022-10-31 17:05:59.774  INFO 12964 --- [0.0-5523-exec-6] com.hua.mall.aop.WebLogAspect            : request start, Id: fb9b8c8db87040ceb6ab171e642bc797, Path: /order/create, IP: 127.0.0.1, Params: [OrderCreateRequest(receiverName=张天师, receiverMobile=1886666888, receiverAddress=China BeiJing), org.apache.catalina.connector.RequestFacade@3b878a65]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d7ea22a] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: SELECT id,user_account,user_password,user_avatar,nickname,gender,personalized_signature,email_address,user_role,create_time,update_time,is_delete FROM user WHERE id=? AND is_delete=0
==> Parameters: 1(Long)
<==    Columns: id, user_account, user_password, user_avatar, nickname, gender, personalized_signature, email_address, user_role, create_time, update_time, is_delete
<==        Row: 1, huauz1, e9cd4dbc2aed67b001142aded0b3c283, https://vkceyugu.cdn.bspapp.com/VKCEYUGU-76abc9c0-964e-44a3-897f-fbeb0c2e276f/6c2f193c-7afb-403c-8f4a-789a1dfe972e.png, 用户, 1, 测试User, test@qq.com, user, 2022-10-24 14:25:37, 2022-10-30 08:20:38, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1d7ea22a]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a83d246] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: select c.id as id, p.id as productId, c.user_id as userId, c.quantity as quantity, c.selected as selected, p.price as price, p.product_name as productName, p.image as productImage from cart c left join product p on p.id = c.product_id where c.user_id = ? and p.product_status = 1
==> Parameters: 1(Long)
<==    Columns: id, productId, userId, quantity, selected, price, productName, productImage
<==        Row: 27, 27, 1, 6, 1, 222, 波士顿大龙虾鲜活冰鲜海鲜水产大只装波龙澳洲龙虾 400-500g 一只装, http://127.0.0.1:8080/images/new-longxia.png
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3a83d246]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@42713d34] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: SELECT id,image,detail,product_name,price,stock,category_id,create_time,update_time,product_status FROM product WHERE id=?
==> Parameters: 27(Long)
<==    Columns: id, image, detail, product_name, price, stock, category_id, create_time, update_time, product_status
<==        Row: 27, http://127.0.0.1:8080/images/new-longxia.png, 类别:澳洲龙虾特产品类:澳洲龙虾国产/进口:国产保存状态:冰鲜原产地:中国大陆, 波士顿大龙虾鲜活冰鲜海鲜水产大只装波龙澳洲龙虾 400-500g 一只装, 222, 22122, 13, 2020-06-28 16:06:34, 2022-10-05 23:03:44, 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@42713d34]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@468c0f2c] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: SELECT id,image,detail,product_name,price,stock,category_id,create_time,update_time,product_status FROM product WHERE id=?
==> Parameters: 27(Long)
<==    Columns: id, image, detail, product_name, price, stock, category_id, create_time, update_time, product_status
<==        Row: 27, http://127.0.0.1:8080/images/new-longxia.png, 类别:澳洲龙虾特产品类:澳洲龙虾国产/进口:国产保存状态:冰鲜原产地:中国大陆, 波士顿大龙虾鲜活冰鲜海鲜水产大只装波龙澳洲龙虾 400-500g 一只装, 222, 22122, 13, 2020-06-28 16:06:34, 2022-10-05 23:03:44, 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@468c0f2c]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@123c0c30] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: UPDATE product SET image=?, detail=?, product_name=?, price=?, stock=?, category_id=?, create_time=?, update_time=?, product_status=? WHERE id=?
==> Parameters: http://127.0.0.1:8080/images/new-longxia.png(String), 类别:澳洲龙虾特产品类:澳洲龙虾国产/进口:国产保存状态:冰鲜原产地:中国大陆(String), 波士顿大龙虾鲜活冰鲜海鲜水产大只装波龙澳洲龙虾 400-500g 一只装(String), 222(Integer), 22116(Integer), 13(Long), 2020-06-28 16:06:34.0(Timestamp), 2022-10-05 23:03:44.0(Timestamp), 1(Integer), 27(Long)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@123c0c30]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2c7da830] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: DELETE FROM cart WHERE id=?
==> Parameters: 27(Integer)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2c7da830]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@edd6fff] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@357a2afe] will not be managed by Spring
==>  Preparing: INSERT INTO order ( order_no, user_id, total_price, receiver_name, receiver_mobile, receiver_address, order_status ) VALUES ( ?, ?, ?, ?, ?, ?, ? )
==> Parameters: 2022103117060028467(String), 1(Long), 1332(Integer), 张天师(String), 1886666888(String), China BeiJing(String), 10(Integer)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@edd6fff]
2022-10-31 17:06:00.426 ERROR 12964 --- [0.0-5523-exec-6] c.h.m.exception.GlobalExceptionHandler   : runtimeException

org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
user_id,
total_price,
receiver_name,
receiver_mobile,
receive' at line 1
### The error may exist in com/hua/mall/mapper/OrderMapper.java (best guess)
### The error may involve com.hua.mall.mapper.OrderMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO order  ( order_no, user_id, total_price, receiver_name, receiver_mobile, receiver_address, order_status )  VALUES  ( ?, ?, ?, ?, ?, ?, ? )
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
user_id,
total_price,
receiver_name,
receiver_mobile,
receive' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
user_id,
total_price,
receiver_name,
receiver_mobile,
receive' at line 1
	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239) ~[spring-jdbc-5.3.23.jar:5.3.23]
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) ~[spring-jdbc-5.3.23.jar:5.3.23]
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91) ~[mybatis-spring-2.0.7.jar:2.0.7]
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) ~[mybatis-spring-2.0.7.jar:2.0.7]
	at com.sun.proxy.$Proxy88.insert(Unknown Source) ~[na:na]
	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:272) ~[mybatis-spring-2.0.7.jar:2.0.7]
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:59) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) ~[mybatis-plus-core-3.5.2.jar:3.5.2]
	at com.sun.proxy.$Proxy103.insert(Unknown Source) ~[na:na]
	at com.baomidou.mybatisplus.extension.service.IService.save(IService.java:63) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
	at com.hua.mall.service.impl.OrderServiceImpl.createOrder(OrderServiceImpl.java:100) ~[classes/:na]
	at com.hua.mall.service.impl.OrderServiceImpl$$FastClassBySpringCGLIB$$c5091be9.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:704) ~[spring-aop-5.3.23.jar:5.3.23]
	at com.hua.mall.service.impl.OrderServiceImpl$$EnhancerBySpringCGLIB$$a0e0e7a4.createOrder(<generated>) ~[classes/:na]
	at com.hua.mall.controller.OrderController.create(OrderController.java:30) ~[classes/:na]
	at com.hua.mall.controller.OrderController$$FastClassBySpringCGLIB$$c2f5844b.invoke(<generated>) ~[classes/:na]
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:793) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89) ~[spring-aop-5.3.23.jar:5.3.23]
	at com.hua.mall.aop.WebLogAspect.doInterceptor(WebLogAspect.java:49) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_341]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_341]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763) ~[spring-aop-5.3.23.jar:5.3.23]
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708) ~[spring-aop-5.3.23.jar:5.3.23]
	at com.hua.mall.controller.OrderController$$EnhancerBySpringCGLIB$$ac1ba56c.create(<generated>) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_341]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_341]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964) ~[spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) [spring-webmvc-5.3.23.jar:5.3.23]
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) [spring-webmvc-5.3.23.jar:5.3.23]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:681) [tomcat-embed-core-9.0.65.jar:4.0.FR]
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) [spring-webmvc-5.3.23.jar:5.3.23]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [tomcat-embed-core-9.0.65.jar:4.0.FR]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) [spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.23.jar:5.3.23]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) [spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.23.jar:5.3.23]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.3.23.jar:5.3.23]
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) [spring-web-5.3.23.jar:5.3.23]
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.65.jar:9.0.65]
	at java.lang.Thread.run(Thread.java:750) [na:1.8.0_341]
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
user_id,
total_price,
receiver_name,
receiver_mobile,
receive' at line 1
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) ~[mysql-connector-java-8.0.30.jar:8.0.30]
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-java-8.0.30.jar:8.0.30]
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) ~[mysql-connector-java-8.0.30.jar:8.0.30]
	at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:354) ~[mysql-connector-java-8.0.30.jar:8.0.30]
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:497) ~[druid-1.2.8.jar:1.2.8]
	at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source) ~[na:na]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) ~[mybatis-3.5.9.jar:3.5.9]
	at com.sun.proxy.$Proxy148.execute(Unknown Source) ~[na:na]
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47) ~[mybatis-3.5.9.jar:3.5.9]
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74) ~[mybatis-3.5.9.jar:3.5.9]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_341]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_341]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) ~[mybatis-3.5.9.jar:3.5.9]
	at com.sun.proxy.$Proxy146.update(Unknown Source) ~[na:na]
	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50) ~[mybatis-3.5.9.jar:3.5.9]
	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) ~[mybatis-3.5.9.jar:3.5.9]
	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) ~[mybatis-3.5.9.jar:3.5.9]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_341]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_341]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49) ~[mybatis-3.5.9.jar:3.5.9]
	at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106) ~[mybatis-plus-extension-3.5.2.jar:3.5.2]
	at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) ~[mybatis-3.5.9.jar:3.5.9]
	at com.sun.proxy.$Proxy145.update(Unknown Source) ~[na:na]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194) ~[mybatis-3.5.9.jar:3.5.9]
	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181) ~[mybatis-3.5.9.jar:3.5.9]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_341]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_341]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_341]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_341]
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.7.jar:2.0.7]
	... 86 common frames omitted
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order>
        implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Resource
    private OrderItemService orderItemService;

    @Resource
    private ProductService productService;

    @Resource
    private UserService userService;

    @Resource
    private CartService cartService;

    @Override
    public String createOrder(OrderCreateRequest orderCreateRequest, HttpServletRequest request) {
        //拿到用户ID
        Long userId = userService.getLoginUser(request).getId();
        //从购物车查找已勾选的商品,添加到 cartVOListTemp 中。
        List<CartVO> cartVOList = cartService.cartList(userId);
        ArrayList<CartVO> cartVOListTemp = new ArrayList<>();
        for (int i = 0; i < cartVOList.size(); i++) {
            CartVO cartVO = cartVOList.get(i);
            if (cartVO.getSelected().equals(CartConstant.CHECKED)) {
                cartVOListTemp.add(cartVO);
            }
        }
        cartVOList = cartVOListTemp;
        //如果购物车已勾选列表的为空,报错
        if (CollectionUtils.isEmpty(cartVOList)) {
            throw new BusinessException(ErrorCode.NOT_FOUND_ERROR, "购物车为空");
        }
        // 判断商品是否存在、上下架状态、库存
        validSaleStatusAndStock(cartVOList);
        // 把购物车对象转化为 order_item 对象
        List<OrderItem> orderItemList = cartVOListToOrderItemList(cartVOList);
        // 扣库存
        for (int i = 0; i < orderItemList.size(); i++) {
            OrderItem orderItem = orderItemList.get(i);
            // 查找商品
            Product product = productService.getById(orderItem.getProductId());
            // 原商品数量 - 当前购买数量 = 当前商品库存
            int stock = product.getStock() - orderItem.getQuantity();
            if (stock < 0) {
                throw new BusinessException(ErrorCode.PARAMS_ERROR, "库存不足");
            }
            // 重新设置当前商品数量
            product.setStock(stock);
            productService.updateById(product);
        }
        // 把购物车中已勾选的商品删除
        removeCart(cartVOList);
        // 生成订单
        Order order = new Order();
        // 生成订单号
        String orderNo = OrderCodeFactory.getOrderCode(userId);
        order.setOrderNo(orderNo);
        order.setUserId(userId);
        order.setTotalPrice(totalPrice(orderItemList));
        order.setReceiverName(orderCreateRequest.getReceiverName());
        order.setReceiverMobile(orderCreateRequest.getReceiverMobile());
        order.setReceiverAddress(orderCreateRequest.getReceiverAddress());
        order.setOrderStatus(OrderCode.UNPAID.getCode());
        //插入数据库
        this.save(order);
        // 循环保存到 order_item 表
        for (int i = 0; i < orderItemList.size(); i++) {
            OrderItem orderItem = orderItemList.get(i);
            orderItem.setOrderNo(order.getOrderNo());
            boolean save = orderItemService.save(orderItem);
            if (!save) {
                throw new BusinessException(ErrorCode.SYSTEM_ERROR);
            }
        }
        // 循环结果返回
        return orderNo;
    }

    /**
     * 总价
     *
     * @param orderItemList
     * @return
     */
    private Integer totalPrice(List<OrderItem> orderItemList) {
        Integer totalPrice = 0;
        for (int i = 0; i < orderItemList.size(); i++) {
            OrderItem orderItem = orderItemList.get(i);
            totalPrice += orderItem.getTotalPrice();
        }
        return totalPrice;
    }

    /**
     * 删除购物车内商品
     *
     * @param cartVOList
     */
    private void removeCart(List<CartVO> cartVOList) {
        for (int i = 0; i < cartVOList.size(); i++) {
            CartVO cartVO = cartVOList.get(i);
            boolean remove = cartService.removeById(cartVO.getId());
            if (!remove) {
                throw new BusinessException(ErrorCode.SYSTEM_ERROR);
            }
        }
    }

    /**
     * Oder 遍历到 OrderItem
     *
     * @param cartVOList
     * @return
     */
    private List<OrderItem> cartVOListToOrderItemList(List<CartVO> cartVOList) {
        List<OrderItem> orderItemList = new ArrayList<>();
        for (int i = 0; i < cartVOList.size(); i++) {
            CartVO cartVO = cartVOList.get(i);
            OrderItem orderItem = new OrderItem();
            orderItem.setProductId(cartVO.getProductId());
            // 快照信息
            orderItem.setProductName(cartVO.getProductName());
            orderItem.setProductImg(cartVO.getProductImage());
            orderItem.setUnitPrice(cartVO.getPrice());
            // 数量
            orderItem.setQuantity(cartVO.getQuantity());
            // 总价
            orderItem.setTotalPrice(cartVO.getTotalPrice());
            orderItemList.add(orderItem);
        }
        return orderItemList;
    }

    /**
     * 验证购物车内商品
     *
     * @param cartVOList
     */
    private void validSaleStatusAndStock(List<CartVO> cartVOList) {
        for (int i = 0; i < cartVOList.size(); i++) {
            CartVO cartVO = cartVOList.get(i);
            // 判断商品是否为空或售卖状态
            Product product = productService.getById(cartVO.getProductId());
            if (product == null || product.getProductStatus().equals(NOT_SALE)) {
                throw new BusinessException(ErrorCode.NOT_FOUND_ERROR);
            }
            // 判断库存
            if (cartVO.getQuantity() > product.getStock()) {
                throw new BusinessException(ErrorCode.PARAMS_ERROR, "库存不足");
            }
        }
    }

}

问题描述:

MyBatisPlus的Save方法插入数据报 You have an error in your SQL syntax;

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学你好,1、异常信息提示:SQL语法不正确,出现在添加语句中。如下所示:建议同学查看对应的括号是否是中文字符,如果是,则修改为英文字符。

https://img1.sycdn.imooc.com//climg/635f9b91095bfcb608100248.jpg

2、并建议同学查看对应的字段是否与数据库中不一致。

3、如果还存在问题,建议同学使用课程源代码中的SQL试一下。

祝学习愉快!

  • hua987 提问者 #1
    ### SQL: INSERT INTO order  ( order_no, user_id, total_price, receiver_name, receiver_mobile, receiver_address, order_status, postage, payment_type )  VALUES  ( ?, ?, ?, ?, ?, ?, ?, ?, ? )
    ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
    user_id,
    total_price,
    receiver_name,
    receiver_mobile,
    receive' at line 1
    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order  ( order_no,
    user_id,
    total_price,
    receiver_name,
    receiver_mobile,
    receive' at line 1

    用课件中的SQL也是这个问题

    2022-10-31 19:10:19
  • hua987 提问者 #2

    搞定了添加库名

    https://img1.sycdn.imooc.com//climg/635fc1210952695a05400221.jpg

    2022-10-31 20:39:36
  • 好帮手慕小尤 回复 提问者 hua987 #3

    同学解决了就好,继续加油!

    祝学习愉快!

    2022-11-01 09:49:17
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师