2

I am getting the above mentioned exception while executing the SQL query in Java.

statement2.executeUpdate("INSERT INTO visit_header" 
    + "VALUES('"+visitnumber+"','"+date+"','"+cookie+"','"+ip+"')");

I want to know where it is going wrong.

4

2 回答 2

5

您忘记在 visit_header 和值之间放置空格:

statement2.executeUpdate("INSERT INTO visit_header" + " VALUES ('"+visitnumber+"','"+date+"','"+cookie+"','"+ip+"')");
于 2013-04-24T06:30:18.520 回答
5

根据最初的外观,您的 sql 查询有问题:

statement2.executeUpdate("INSERT INTO visit_header" + "VALUES 

应该

statement2.executeUpdate("INSERT INTO visit_header " + "VALUES  //Note space after header

visit_header 和 VALUES 之间没有空格,所以您的查询是这样的:

INSERT INTO visit_headerVALUES 

这是错误的。

于 2013-04-24T06:30:51.300 回答