MySQL查询在phpMyAdmin中工作,但在java中不工作
我有疑问MySQL查询在phpMyAdmin中工作,但在java中不工作,java,mysql,Java,Mysql,我有疑问 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中运行良好,但它给出了一个例
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);
(我使用以下方法创建连接:)
怎么了
编辑:
我打算将int和boolean保存为字符串
我还尝试将graves(`)替换为“”和“我猜查询的值正在填充Java变量。如果是这样,我会检查“[[Value 1,Value 2]]”是否正确填充了字符串值。MySQL异常通常发生在错误消息中提供的查询部分之前,因此
the right syntax to use near ')'
表示问题可能是'[[Value 1,Value 2]]'或
rotation~messages~messages
)尝试替换“(重音严重,或其他)在java代码中使用“
。首先,停止在整数字段中添加撇号,它们是用于字符串的。其次,为java代码提供查询。@MostyMostacho我打算将整数存储为字符串。如果查询引发异常,则它无法正常工作(仅根据定义)@PM77-1 phpMyAdmin不会抱怨查询,而是执行它应该执行的操作(插入行)
the right syntax to use near ')'