JDBC MySql bind variable syntax error in where clause

后端 未结 3 809
无人共我
无人共我 2021-01-24 02:22

I am getting this error: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server

3条回答
  •  别那么骄傲
    2021-01-24 03:15

    Don't use executeQuery(String) with prepared statements...

    Instead of....

    ResultSet rs = stmt.executeQuery(sql);
    

    use...

    ResultSet rs = stmt.executeQuery();
    

    Take a look at How to use Prepared Statements for more details

提交回复
热议问题