【已解决】bad SQL grammar [select* from artitle where keyWord like %]; nested exception is java.sql.SQLSy

org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select* from artitle where keyWord like %]; 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 ‘%’ at line 1

问题所在 模糊查询的时候,like后面的模糊查询语法出错
出错代码

String sql="select * from artitle where keyWord like '%?%'";

解决方法 把模糊查询后的语法改一下,改成下文:

String sql="select * from artitle where keyWord like '%' ? '%'";

就解决掉问题了

你可能感兴趣的:(JDBC,Java,SQL,sql,数据库,database)