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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM