简体   繁体   English

获取com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL语法

[英]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.

相关问题 SQL 语法错误:“com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException” - SQL syntax error: “com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException” com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL 语法错误 - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: error in SQL syntax com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException jdbc代码中的错误-&gt; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误 - error in jdbc code -> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:获取严重级别:null - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : getting a SEVERE: null 线程“ main”中的异常com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误 - Exception in thread “main” com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误;(休眠) - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;(Hibernate) 无法创建配置文件com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法错误; - unable to create the profile com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; 严重:null<br> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有错误; - SEVERE: null<br> com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM