做课设微信小程序的时候,微信小程序请求后端接口,后端接口报500,
错误提示为
Declare(id=null, declareNumber=null, declareTitle=没网了, declareTime=null, declareLocal=31栋614, declareDescribe=网络不稳定, photo=G:\upload\2021-06-04\bf1e3f96-2c6c-4a25-bbc2-7da717a3c0c2.jpg;G:\upload\2021-06-04\cc47fb76-88a0-4dc1-86df-1c7d477a9c43.jpg, phone=13652653699, userId=1, declareTypeId=1, levelId=1, declareState=null, isDeleted=null)
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@714d5d70] was not registered for synchronization because synchronization is not active
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@4ca2899b] will not be managed by Spring
==> Preparing: INSERT INTO declare ( declare_number, declare_title, declare_time, declare_local, declare_describe, photo, phone, user_id, declare_type_id, level_id, declare_state ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
==> Parameters: BX202106041632502427(String), 没网了(String), 2021-06-04 16:32:50.47(Timestamp), 31栋614(String), 网络不稳定(String), G:\upload\2021-06-04\bf1e3f96-2c6c-4a25-bbc2-7da717a3c0c2.jpg;G:\upload\2021-06-04\cc47fb76-88a0-4dc1-86df-1c7d477a9c43.jpg(String), 13652653699(String), 1(Integer), 1(Integer), 1(Integer), 0(Byte)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@714d5d70]
2021-06-04 16:32:50.724 ERROR 13752 --- [nio-8088-exec-1] 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.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 'declare ( declare_number,
declare_title,
declare_time,
declare_local,
declare_d' at line 1
### The error may exist in com/yeqifu/mapper/DeclareMapper.java (best guess)
### The error may involve com.yeqifu.mapper.DeclareMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO declare ( declare_number, declare_title, declare_time, declare_local, declare_describe, photo, phone, user_id, declare_type_id, level_id, declare_state ) 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 'declare ( declare_number,
declare_title,
declare_time,
declare_local,
declare_d' 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 'declare ( declare_number,
declare_title,
declare_time,
declare_local,
declare_d' at line 1] with root 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 'declare ( declare_number,
declare_title,
declare_time,
declare_local,
declare_d' at line 1
我把这条插入语句放到navicat中去运行的时候,发现还是报错
那这肯定是sql的问题了,后面发现是我数据库表declare中有一个字段叫描述
describe
,然后发现是mysql的关键字,我就修改了这个字段,但是还是报这个错,最后发现我的表名也是关键字declare
,修改表名之后就解决了这个问题。