问题描述:
在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.
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!