1

我有查询

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();

怎么了?

编辑

我打算将整数和布尔值保存为字符串

我还尝试将坟墓 (`) 换成 ' 和 "

4

1 回答 1

0

我猜查询的值是用 Java 变量填充的。如果是这样,我会检查 '[[Value 1, Value 2]]' 是否正确填充了字符串值。MySQL 异常通常发生在错误消息中提供的查询部分之前,所以...

the right syntax to use near ')'

表示问题可能是'[[Value 1, Value 2]]')rotation~messages~messages)

于 2013-10-26T19:05:58.067 回答