把preparestatement换成statement看看

解决方案 »

  1.   

    几个会产生错误的地方
    1。
    if((user_id.length()==0)||(password.length()==0)){
      out.println("user_id or password not null!");
    当用户未输入user_id等时,上面的方法会产生空指针错误,改为
    if(user_id==null||password==null){
      out.println("user_id or password not null!");
    }
    2.
    insert_stm.executeQuery();
       //则把此用户名及密码插入到数据库的表中
    插入数据用:
    insert_stm.executeUpdate();
       //则把此用户名及密码插入到数据库的表中
    3。
      String temp_password=null;
      //声明储存查询结果中密码属性的变量
    注意作用域范围,最好放到头部:
    <%
     String user_id=request.getParameter("user_id");
     String password=request.getParameter("password");
     //接收登录页面表单传过来的用户名和密码的参熟
     String temp_password=null;
      //声明储存查询结果中密码属性的变量
    %>
    4.
    if(password.regionMatches(0,temp_password,0,password.length()))
    字符串比较用equals最好:
    if(password.equals(temp_password))
      

  2.   

    一般情况下用Statement比prepareStatement简单方便
      

  3.   

    1、
    if((user_id.length()==0)||(password.length()==0)){
      out.println("user_id or password not null!");
    -->
    if(user_id.length()==null||password.length()==null||user_id.length()==0||password.length()==0){
      out.println("user_id or password not null!");
    2、
    ResultSet result=select_stm.executeQuery();
    -->
    ResultSet result=select_stm.executeUpdate();