为了账号安全,请及时绑定邮箱和手机立即绑定

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException?

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException?

忍帅锅 2018-04-26 22:03:56
com.mysql.jdbc.exceptions.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 '?,?,?,?,?,?,?,?,?,?)' at line 1利用jsp写登录界面时出现上面报错,是什么原因呢?<%try{  conn = DBHelper.getConnection();  String sql = "insert into userinfo (yid,username,password,sex,age,addr,tel,sid,email,balance) values (?,?,?,?,?,?,?,?,?,?)";//插入语句,”?”表示接受参数值   pstmt = conn.prepareStatement(sql);  //给sql语句中的变量赋值  pstmt.setString(1, request.getParameter("yid"));  pstmt.setString(2, request.getParameter("username"));  pstmt.setString(3, request.getParameter("password"));  pstmt.setString(4, request.getParameter("sex"));  pstmt.setString(5, request.getParameter("age"));  pstmt.setString(6, request.getParameter("address"));  pstmt.setString(7, request.getParameter("tel"));  pstmt.setString(8, request.getParameter("id"));  pstmt.setString(9, request.getParameter("email"));  pstmt.setString(10, request.getParameter("balance"));  int updatenumber =  pstmt.executeUpdate(sql);  if(updatenumber!=0)  {  request.getRequestDispatcher("login_success.jsp").forward(request, response);  }  else  {  response.sendRedirect("login_failure.jsp");  }   }catch(Exception e) {    e.printStackTrace() ;} %> 
查看完整描述

1 回答

?
忍帅锅

TA贡献2条经验 获得超1个赞

已解决:

     String sql ="insert into userinfo(yid,username,password,sex,age,addr,tel,email,sid,balance) values("+yid+","+username+","+password+","+sex+","+age+","+addr+","+tel+","+email+","+sid+","+balance+")"; 

     这样写就通过了!

查看完整回答
1 反对 回复 2018-04-26
  • 1 回答
  • 0 关注
  • 3738 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信