com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException错误求助!
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:YouhaveanerrorinyourSQLsynt...
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 'set sex='?”·',set major='è????—???',set classes='111'set tel='123456'' at line 1
错误代号如上,对应的程序代码是:
try {
stmt=conn.createStatement();
StringBuffer sql=new StringBuffer("update student set name='");
sql.append(stu.getName()).append("',set sex='").append(stu.getSex()).append("',set major='").append(stu.getMajor()).append("',set classes='").append(stu.getClasses()).append("'set tel='").append(stu.getTel()).append("'");
stmt.executeUpdate(sql.toString());
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
stmt.close();
DBUtil.close(conn);
} catch (SQLException e) {
e.printStackTrace();
}
}
这部分到底是哪里出错了呢?还请各位帮帮忙,最后的难关了! 展开
错误代号如上,对应的程序代码是:
try {
stmt=conn.createStatement();
StringBuffer sql=new StringBuffer("update student set name='");
sql.append(stu.getName()).append("',set sex='").append(stu.getSex()).append("',set major='").append(stu.getMajor()).append("',set classes='").append(stu.getClasses()).append("'set tel='").append(stu.getTel()).append("'");
stmt.executeUpdate(sql.toString());
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
stmt.close();
DBUtil.close(conn);
} catch (SQLException e) {
e.printStackTrace();
}
}
这部分到底是哪里出错了呢?还请各位帮帮忙,最后的难关了! 展开
1个回答
2014-12-26 · 知道合伙人互联网行家
关注
展开全部
:select * from user where id=1 limit 0,10这种写法是没错的,不过你传的参数错了,你看错误“check the manual that corresponds to your MySQL server version for the right syntax to use near '-5,5' at line 1”你的startno传的是-5这里这个...
追问
你这复制粘贴都不完整。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询