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语句,放在客户端执行一下
解决mysql 8报错 ERROR 1064 (42000): You have an error in your SQL syntax
解决mysql 8报错 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to …
有同事说从mysql5.7换到mysql8,一样的存储过程,在mysql5.7执行没问题,在mysql8就报上面那个错,就有问题,帮忙调试了一波,发现是自定义关键字没有使用反引号的原因
解决办法:
row_number全部替换成 `row_number`
根本原因:mysql8自定义的关键字需要使用反引号标注
细节决定成败!编写SQL语句一定要遵循语法规范!
以上是关于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