设为首页 加入收藏

TOP

IDEA+MySQL实现登录注册的注册验证时出现 Cannot resolve query parameter '2'
2019-09-17 18:40:16 】 浏览:28
Tags: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.

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇一条查询sql的执行流程和底层原理 下一篇mysql 导出数据报错: row must b..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目