near '1,'??‰?????”??‰','35',1,35)' at line 1有人知道怎么回事吗

tuke_tuke 2015-09-20 12:22:02
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 '1,'??‰?????”??‰','35',1,35)' at line 1
代码是这样的:
//插入书籍
public boolean InsertBook(String userid,Book b){
conn = DB.getCon(); //获取数据库连接
System.out.println(userid);//userid是表名,是中文字符的
if(conn!=null){
try {

String sql="insert into "+userid+"values(?,?,?,?,?)";
PreparedStatement pstm=conn.prepareStatement(sql);
pstm.setInt(1, b.getBookId());
System.out.println(b.getName());//值是'三国演义'
pstm.setString(2, b.getName());//书的名字是中文字符的
pstm.setString(3, b.getPrice());
pstm.setInt(4, 1);
pstm.setInt(5, Integer.parseInt(b.getPrice()));
System.out.println("语句没错");
pstm.executeUpdate();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}
...全文
103 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2015-09-20
  • 打赏
  • 举报
回复
按下贴中的方法检查字符集设置。并贴出以供分析。 http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx MySQL 中文显示乱码
rick-he 2015-09-20
  • 打赏
  • 举报
回复
汉字不能插入,看下你的数据库字符集

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧