日期:2014-05-18  浏览次数:20677 次

又是Null?
Java code
package com.fuyou.servlet;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fuyou.util.DBConnection;
import com.fuyou.util.mvconnection;

public class loginservlet extends HttpServlet {
    private DBConnection dbc = new DBConnection();

    private static final long serialVersionUID = -3265621922663327137L;

    public loginservlet() {

    }

    public void destroy() {
        super.destroy();

    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String conformPswd = "";
        String sql = "select * from user where username='" + username + "'";

        ResultSet rs = null;
        mvconnection mvc = new mvconnection();
        if (mvc != null) {
            rs = mvc.getResultSet(sql);
        } else {
            return;
        }
        if (rs != null) {
            try {
                if (rs.getString("password") != null) {
                    conformPswd = rs.getString("PASSWORD");
                }
                return;
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                this.dbc.closeResultSet(rs);
            }
        }
        if (password.equals(conformPswd)) {

        }

    }

    public void init() throws ServletException {

    }

}

异常信息:
type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

java.lang.NullPointerException
com.mysql.jdbc.ResultSet.buildIndexMapping(ResultSet.java:596)
com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:946)
com.mysql.jdbc.ResultSet.getString(ResultSet.java:5613)
com.fuyou.servlet.loginservlet.doPost(loginservlet.java:50)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)




------解决方案--------------------
哪是第50行哦,数了半天数到try去了,看来代码给的不准确哟。
------解决方案--------------------
不可能哟,你上头已经判断了rs != null咯,下面咋也没有其他可能是null咯,再查查撒。
------解决方案--------------------
mvconnection mvc = new mvconnection();
mvc.getResultSet(sql);
把这mvconnection类及相关代码贴上来
------解决方案--------------------
哦,好像有点儿明白了,原来是因为column不存在,所以