問題描述: 在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'
貼上創建鏈接的代碼:
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.