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() ;
}
%>
忍帅锅