[英]Getting com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SQL syntax
do
{
String mid=res.getString(1);
String model=res.getString(2);
String name=res.getString(3);
int price=res.getInt(4);
String pcolor=res.getString(5);
String imei=res.getString(6);
java.sql.Date date=res.getDate(7);
String access=res.getString(8);
if(id.equals(mid) || id.equals(imei))
{
System.out.println("iam inside");
PreparedStatement prp=con2.prepareStatement("insert into msearch values(?,?,?,?,?,?,?,?)");
prp.setString(1,mid);
prp.setString(2,model);
prp.setString(3,name);
prp.setInt(4,price);
prp.setString(5,pcolor);
prp.setString(6,imei);
prp.setDate(7,date);
prp.setString(8,access);
prp.executeUpdate();
System.out.println("iam inside2");
rows++;
b=1;
jTextField1.setText("");
}
}while(res.next());
I am new to mysql 我是mysql新手
I am trying to execute above code ,I got 我正在尝试执行上述代码,我得到了
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 检查与您的MySQL服务器版本相对应的手册,以在第1行的''附近使用正确的语法
what should be the problem,please help, 应该是什么问题,请帮忙,
像这样更改您的prepareStatement;
insert into msearch (mid, model, name, price, pcolor, imei, date, access) values(?,?,?,?,?,?,?,?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.