我想插入一些数据到MySQL数据库,但我得到一个错误,我找不到错误的代码。我不擅长mysql。JDBC MySQL查询错误?
String insertQuery = "insert into books(title, author, description, prize)values("
+ title
+ ","
+ author
+ ","
+ desc
+ ", "
+ prize
+ ");";
mysql> describe books;
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| book_id | int(11) | NO | PRI | NULL | |
| title | varchar(64) | YES | | NULL | |
| author | varchar(64) | YES | | NULL | |
| description | varchar(500) | YES | | NULL | |
| prize | float | YES | | NULL | |
| added | datetime | YES | | NULL | |
+-------------+--------------+------+-----+---------+-------+
6 rows in set (0.01 sec)
我得到的是错误,
Query: insert into books(title, author, description, prize)values(sfdfdf,fdfdf,Please limiasasaat your response to 500 characters., 78.9);
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 'limiasasaat your response to 500 characters., 78.9)' at line 1
请避免链接到RoseIndia。 http://balusc.blogspot.in/2008/06/what-is-it-with-roseindia.html。 –
我添加了参考bro的链接,这就是为什么我根据OP的问题更新了准备好的语句的答案。例如, –
+1。 –