關於...corresponds to your MySQL server version for the right syntax to use near '?' at line 1的解決辦法


完整報錯信息:

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

踩坑經歷:

在有道詞典翻譯后,“你的SQL語法有錯誤;檢查手冊對應的MySQL服務器版本的正確語法附近'?'在第1行”。這句話的意思是在?附近的SQL語句有錯誤。當我去看整個SQL語句時,發現SQL語句並沒有寫錯。然后我就覺得應該是PreparedStatement這個類的預編譯或編譯的方法那出錯了,於是我去看了.prepareStatement()和.executeQuery()方法,發現.executeQuery()傳入了sql語句,沒想到自己還遇到了這種低級的錯誤。。。

解決方法:

將ppstm.executeQuery(sql);中的sql去掉,改成ppstm.executeQuery();


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 MySQL 8.0:check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'password'' at line 1 check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '123456' WITH GRANT OPTION' at line 1 解決:[Err] 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 mysq添加外鍵報錯:check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=InnoDB' at line 1 【異常】MySQL建表報錯: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 '"order"' at line 1 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 'groups)VALUES('1','hh','hh@163.com','Boss')' at line 1 check the manual that corresponds to your MySQL server version for the right syntax to use near '(0) NULL DEFAULT NULL COMMENT check the manual that corresponds to your MySQL server version for the right syntax to use near check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc Django進行數據遷移時,報錯:(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 '(6) NOT NULL)' at line 1")
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM