IDEA+MySQL实现登录注册的注册验证时出现 Cannot resolve query parameter '2'

问题描述:

在IDEA+MySQL+Tomcat 实现登录注册JSP的注册信息INSERT验证时出现 Cannot resolve query parameter ‘2‘

贴上创建链接的代码:

 if(conn != null){ String sql = "SELECT *FROM login_info WHERE DBuser=?"; pstm = conn.prepareStatement(sql); pstm.setString(1,user); rs = pstm.executeQuery(); if(!rs.next()){ sql = "INSERT INTO login_info(DBuser,DBpass,Age,Email,Gender,Hobby,Education,Introduce) VALUE(?,?,?,?,?,?,?,?)"; pstm = conn.prepareStatement(sql); pstm.setString(1,user); pstm.setString(2,pass); pstm.setString(3,age); pstm.setString(4,email); pstm.setString(5,gender); pstm.setString(6,hobby); pstm.setString(7,education); pstm.setString(8,introduce); pstm.executeUpdate(); }else{ out.println("该用户名已存在"); } int row = pstm.executeUpdate(); if(row>0){ out.println("成功添加"+row+"条数据!"); } } else{ out.print("连接失败!"); } }catch (Exception e) { out.print("数据库连接异常!"); out.println(e); e.printStackTrace(); }finally { try { if (rs != null) rs.close(); if (pstm != null) pstm.close(); if (conn != null) conn.close(); } catch (Exception e) { e.printStackTrace(); } }

运行起来显示

数据库连接异常

查看异常显示

 The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

 

相关文章