check MySQL server version for the right syntax to use near 'id=\'W5M0MpCehiHzreSzNTczkc9d\'?>

Java EE 报错
Exception in thread "main" 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 'id=\'W5M0MpCehiHzreSzNTczkc9d\'?>
代码:
static void create() throws SQLException, IOException{
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try{
conn = JdbcUtils.getConnection();
String sql = "insert into toufa values(?)";
ps = conn.prepareStatement(sql);
File file = new File("ss.jpg");
InputStream in = new BufferedInputStream(new FileInputStream(file));
ps.setBinaryStream(1, in,(int)file.length());
int i = ps.executeUpdate();
in.close();
System.out.println("i="+i);
}finally{
JdbcUtils.free(rs, ps, conn);
}
}
大神们,怎么办啊!!!
当前问题共有如下(1)个解决方案
  • franzhong
    franzhong
    你的最终SQL语句语法有误,打印完整的执行语句,在id=\'W5...前后有字段不匹配情况
    你的表段id是否是int型?如果是,后面为啥条件为字符串?id=\'W5M0M....
    将语句手动修改测试一下就知道,比如id=123 .....测试一下,无错误就找到地方了
    接着去修正那个部分内容,为什么id会是一个定符串

    更多参考:Mysql错误码及释意大全
    http://snowcoal.com/article/732.html
上一篇:1、Apache启动失败,请检查相关配置。√MySQL5.1已启动。求解决!
下一篇:phpmyadmin和navicat for mysql这两个有什么不同?