欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-04-05 21:30:23
问题描述: 在IDEA+MySQL+Tomcat 实现登录注册JSP的注册信息INSERT验证时出现 Cannot resolve query parameter '2' 贴上创建链接的代码: 运行起来显示 数据库连接异常 查看异常显示 The origin server did not find ......

问题描述:

在idea+mysql+tomcat 实现登录注册jsp的注册信息insert验证时出现 cannot resolve query parameter '2'

IDEA+MySQL实现登录注册的注册验证时出现 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.

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