1、错误:

 Servlet.service() for servlet [dispatcherServlet] in context with path [/system] 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 '"test"' at line 1
### The error may exist in file [D:\dev_project\course\system\target\classes\mapper\TestMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT id,name FROM "test"

原因是sql语句有语法问题。

select “id”,“name” from "user"
其中id和name是user表的字段,问题在三个都不能加双引号,user表名加双引号后报上述错误,而字段名加双引号会被识别为字符串,从而在表中找到相应的字符串而不是字段对应的内容。
故正确写法如下:
select id,name from user

 

相关文章:

  • 2021-05-26
  • 2021-09-30
  • 2022-01-02
  • 2021-10-24
猜你喜欢
  • 2021-04-05
  • 2021-11-03
  • 2021-11-18
  • 2021-11-16
相关资源
相似解决方案