Mysql報錯:MySQLSyntaxErrorException: You have an error in your SQL syntax


報錯全文:

2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 'like,time) values('jack','22','22',0,'Apr 26, 2020')' at line 1
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1585)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1500)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1485)
2020-04-27 10:44:56.541 2029-2098/com.example.teamproject W/System.err:     at com.example.teamproject.Dao.insertSheQu(Dao.java:121)
2020-04-27 10:44:56.542 2029-2098/com.example.teamproject W/System.err:     at com.example.teamproject.FaBu$1$1.run(FaBu.java:99)
2020-04-27 10:44:56.542 2029-2098/com.example.teamproject W/System.err:     at java.lang.Thread.run(Thread.java:764)

根據提示可以發現是語法錯誤,由一下幾種情況

  1.插入的數據類型不匹配,例如表中屬性為Date類型,但是插入的數據為字符串,只要改一致就可以。

  2.另外就可能是sql語句錯誤

  3.這個就是我新發現的,昨天晚上也沒解決,然后把sql語句放到sqlyog並將?代替為具體的數據執行,發現還是錯的,然后就思考是不是

near 'like,time中的like與數據庫沖突了,結果一改就好了。


免責聲明!

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



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM