java You have an error in your SQL syntax; check the manual that corresponds
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java You have an error in your SQL syntax; check the manual that corresponds相关的知识,希望对你有一定的参考价值。
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 'S??—è?????é“?','null','?…???????é?????è·???‰é??22??·','null','null','','null','n' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)
at shuju.shuju_s.main(shuju_s.java:39)
shuju_s:39:
st.executeUpdate("insert into IntelligentSearch_nn (infoAutoID,infoid,infotel,infoName,infoIntro,infoAddress,infoKeyWord,infoSection,productName,productTeSe,productPinPai,infoDPContent,infopdname_dl,infopdname_xl,IsDeal,cityid) values ("+re.getInt(2)+",'"+re.getString(3)+"','"+re.getString(4)+"','"+re.getString(5)+"','"+re.getString(6)+"','"+re.getString(7)+"','"+re.getString(8)+"','"+re.getString(9)+"','"+re.getString(10)+"','"+re.getString(11)+"','"+re.getString(12)+"','"+re.getString(13)+"','"+re.getString(14)+"','"+re.getString(15)+"',"+re.getInt(16)+","+re.getInt(17)+")");
String sql = "INSERT INTO IntelligentSearch_nn (infoAutoID,infoid,infotel,infoName,infoIntro,infoAddress,infoKeyWord,infoSection,productName,productTeSe,productPinPai,infoDPContent,infopdname_dl,infopdname_xl,IsDeal,cityid) values (
?, ?, ?, ?<补够那么多个参数>)";
PreparedStatement pst = cn.prepareStatement(sql);
pst.setInt(1, ......);
pst.setString(2, .....);
//这里设置全部的参数
int row=pst.executeUpdate();
System.out.println(row+" row(s) updated. "); 参考技术A 这个属于乱码,是因为字符支持问题导致的。
1、在jsp头处加上 UTF-8
2、mysql数据库支持的字符集修改为 支持UTF-8 ,mysql在没有改动时支持的是latin1 只能是拉丁字,如果打入汉字会出现乱码。 参考技术B 检查一下自己的SQL语句,最后debug一下SQL语句,放在客户端执行一下
异常之You have an error in your SQL syntax
异常如下:
### Error updating database. Cause: 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 \'WHERE id = \'10050\'\' at line 15
仔细看的话 是因为SQL语句中 红色部分 末尾误写 , 所致
一般遇到
check the manual that corresponds to your MySQL server version for the right syntax to use near \'WHERE id = \'10050\'\' at line 15
这种异常语句 在 \'WHERE id = \'10050\'\' 左边仔细查看 可以解决
2017-12-27 15:28:18
以上是关于java You have an error in your SQL syntax; check the manual that corresponds的主要内容,如果未能解决你的问题,请参考以下文章
解决——》ERROR 1064 (42000)You have an error in your SQL syntax; check the manual that corresponds
ERROR 1064 (42000): You have an error in your SQL syntax...
异常之You have an error in your SQL syntax
Mysql错误 ERROR 1064 (42000): You have an error in your SQL syntax