I encountered an error today. Running rankdao. Selectbyid (ID) directly reported an error to me. I didn’t understand it
Error message:
2021-09-22 10:40:58.824 ERROR 8364 --- [nio-8888-exec-4] 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 querying 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 'rank WHERE id=1' at line 1
### The error may exist in com/brilliantZC/music/dao/MusicRankDao.java (best guess)
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=?
### 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 'rank WHERE id=1' 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 'rank WHERE id=1' at line 1] with root cause
At the beginning, Baidu has various methods, some say
- an error is reported when the value of the column in the created table is less than the actual value. The @ resource or @ Autowired annotation is forgotten on the service interface introduced by the controller layer. The method called by the controller layer is private, resulting in distribution failure. Check whether the mapper interface code conforms to the specification (automatically ignored by mybatis plus) OL>
I tried again, but I still couldn’t, so I took the wrong SQL statement and executed it
SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=1
Still report an error
music> SELECT id,song_list_id,consumer_id,score FROM rank WHERE id=1
[2021-09-22 10:55:58] [42000][1064] 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 'rank WHERE id=1' at line 1
Then I was confused. Then I removed the query statement and still reported an error
SELECT id,song_list_id,consumer_id,score FROM rank
Then Baidu saw that because rank is a keyword, it can not be directly used as a non keyword. It needs to be used with `. It can be executed after replacement
SELECT id,song_list_id,consumer_id,score FROM `rank`
Then I modified the table name and solved the error!!!
Read More:
- #error identifier-list parameters may only be used in a function definition
- Idea for Mac setting JVM running parameters to solve running stuck problem
- Apache [error] server reached MaxClients setting, consider raising the MaxClients setting
- Solution to the problem of multiple parameters when using pipeline under Linux
- [Elasticsearch] es 7.12 Root mapping definition has unsupported parameters: _all
- Angular error – can’t resolve all parameters for []
- Create an Apex class that returns contacts based on incoming parameters
- An Ajax HTTP error occurred in drupal7 installation occurred.HTTP Result Code
- Pass parameters to the YML file, ansible playbook command
- After verifying parameters with validation, springboot reports an error: no constructor found in package name + class name
- An error occurs when pymysql uses% d to pass in parameters
- Mybatis passes in multiple parameters to mapper. And uses @param details to report an error
- An error occurred when MySQL backup with mysqldump instruction in MacOS system
- Moveit configuration manipulator error: kin.parameters file
- Four ways to get Django parameters in request
- Idle line number setting and linenumbers modification
- Points for attention in setting up robot framework + Python 3.7.0 environment
- Vue calculates attributes and passes parameters to the computed method
- Unexplained exception 005: uncaught error: can’t resolve all parameters for applicationmodule
- Eclipse automatic prompt setting method and optimization