1
我有查詢MySQL查詢工作在phpMyAdmin,但沒有在Java中
INSERT INTO tests2 (`name`, `val1`, `val2`, `val3`, `rotation~time`, `rotation~messages~countdown_format`, `rotation~messages~messages`) VALUES ('Testing', 'Test', 'false', '0', '21', 'Value', '[[Value 1, Value 2]]')
它工作在phpMyAdmin的罰款,但它給出了一個例外:
com.mysql.jdbc.exceptions.jdbc4.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 ')' at line 1
在Java中調用時使用
statement.execute(query);
(我用這個方法創建連接:)
connection = DriverManager.getConnection(getJDBCString(settings.host(), settings.port(), settings.database()), settings.username(), settings.password());
statement = connection.createStatement();
出了什麼問題?
編輯:
我打算有整數和布爾值保存爲字符串
我也試過換了墳墓(`)「和」
嘗試在java代碼中用'''替換'(重音符號,或者其他)。 – Izmaki
首先,停止在整數字段中添加撇號,它們用於字符串。其次,爲Java代碼提供查詢。 –
@MostyMostacho它是我的意圖,作爲字符串存儲整數 –