Why I am getting NullPointerException error?
===

I tried to figure out what is my mistake but I could not find anything with my code that's called null pointer.

Here is the error page:

    HTTP Status 500 -
    
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    java.lang.NullPointerException
    	myproject.Database.createStatement(Database.java:101)
    	myproject.DoSignIn.checkSignin(DoSignIn.java:91)
    	myproject.DoSignIn.processRequest(DoSignIn.java:40)
    	myproject.DoSignIn.doGet(DoSignIn.java:127)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    	org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
    
    note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
    Apache Tomcat/7.0.22

Here are my code:

Database class:

    package somePackage;
    
    import java.io.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.HashMap;
    import java.util.Properties;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    /**
     *
     * @author mih1406
     */
    public class Database {
        private HashMap dbConfig;
        private Connection dbConnection;
    
        // debugging
        HttpServletRequest request;
        HttpServletResponse response;
    
    
    
        public Database(HttpServletRequest request, HttpServletResponse respnse) {
            this.request = request;
            this.response = response;
            setDatabaseConfig();
    
        }
    
        public void setDatabaseConfig() {
            Properties config = new Properties();
            InputStream configFile;
    
            try {
                configFile = this.getClass().getResourceAsStream("config.properties");
                config.load(configFile);
            } catch(FileNotFoundException fnfe) {
                // TODO properties file not found error
            } catch(IOException ioe) {
                // TODO i/o Exception
            }
    
            String dbHost = config.getProperty("dbHost");
            String dbPort = config.getProperty("dbPort");
            String dbUsername = config.getProperty("dbUsername");
            String dbPassword = config.getProperty("dbPassword");
            String dbName = config.getProperty("dbName");
            String dbPrefix = config.getProperty("dbPrefix");
    
            setDatabaseConfig(dbHost, dbPort, dbUsername, dbPassword,
                    dbName, dbPrefix);
        }
    
        public void setDatabaseConfig(String dbHost, String dbPort, String dbUsername,
                String dbPassword, String dbName, String dbPrefix) {
            dbConfig = new HashMap();
    
            dbConfig.put("dbHost", dbHost);
            dbConfig.put("dbPort", dbPort);
            dbConfig.put("dbUsername", dbUsername);
            dbConfig.put("dbPassword", dbPassword);
            dbConfig.put("dbName", dbName);
            dbConfig.put("dbPrefix", dbPrefix);
        }
    
        public void connect() {
            String dbHost = (String)dbConfig.get("dbHost") + "/";
            String dbPort = (String)dbConfig.get("dbPort");
            String dbUsername = (String)dbConfig.get("dbUsername");
            String dbPassword = (String)dbConfig.get("dbPassword");
            String dbName = (String)dbConfig.get("dbName");
            String dbPrefix = (String)dbConfig.get("dbPrefix");
    
            String dbDriver = "com.mysql.jdbc.Driver";
            String dbURL = "jdbc:mysql://" + dbHost + ":" + dbPort + "/";
    
            try {
                Class.forName(dbDriver);
                dbConnection = DriverManager.getConnection(dbURL, dbURL, dbPassword);
            } catch (ClassNotFoundException cnfe) {
                // TODO Class Exception
            } catch (SQLException sqle) {
                // TODO SQL Exception
            }
        }
    
        public Statement createStatement() {
            try {
                return dbConnection.createStatement();
            } catch(SQLException sqle) {
                // TODO SQL Exception
            }
    
            return null;
        }
    
        public PreparedStatement prepareStatement(String sql) {
            PreparedStatement pstmt = null;
            try {
                pstmt = dbConnection.prepareStatement(sql);
            } catch(SQLException sqle) {
                // TODO SQL Exception
            }
    
            return pstmt;
        }
    
        public void close() {
            try {
                if(dbConnection.isClosed()) {
                    return;
                }
    
                dbConnection.close();
            } catch(SQLException sqle) {
                // TODO SQL Exception
            }
        }
    
        public String getPrefix() {
            return (String)dbConfig.get("dbPrefix");
        }
    
        public String getName() {
            return (String)dbConfig.get("dbName");
        }
    
        public String getHost() {
            return (String)dbConfig.get("dbHost");
        }
    
        public String getPort() {
            return (String)dbConfig.get("dbPort");
        }
    
        public String getUsername() {
            return (String)dbConfig.get("dbUsername");
        }
    
        public String getPassword() {
            return (String)dbConfig.get("dbPassword");
        }
    }


DoSingin class:

    package somePackage;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    /**
     *
     * @author mih1406
     */
    @WebServlet(name = "DoSignIn", urlPatterns = {"/DoSignIn"})
    public class DoSignIn extends HttpServlet {
    
        /**
         * Processes requests for both HTTP
         * <code>GET</code> and
         * <code>POST</code> methods.
         *
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
         */
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            checkValues(request, response);
            checkSignin(request, response);
    
        }
    
        private void checkValues(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            String adminUsername = request.getParameter("adminUsername");
            String adminPassword = request.getParameter("adminPassword");
    
            boolean someEmpty = false;
    
            if((adminUsername.equals("") || adminUsername == null)) {
                someEmpty = true;
                request.setAttribute("emptyEmail", "Required");
            } else {
                request.setAttribute("adminUsername",
                        request.getParameter("adminUsername"));
            }
    
            if((adminPassword.equals("") || adminPassword == null)) {
                someEmpty = true;
                request.setAttribute("emptyPassword", "Required");
            }
    
            if(someEmpty) {
                String url = "signin.jsp";
                forwardToPage(request, response, url);
            }
        }
    
        private void forwardToPage(HttpServletRequest request,
                HttpServletResponse response, String url)
                throws ServletException, IOException {
            RequestDispatcher dispatcher = request.getRequestDispatcher(url);
            dispatcher.forward(request, response);
        }
    
        private void checkSignin(HttpServletRequest request, HttpServletResponse response)
            throws ServletException,IOException {
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String adminUsername = request.getParameter("adminUsername");
            String adminPassword = request.getParameter("adminPassword");
    
            out.println("<br />HereDBCreation!!");
            Database db = new Database(request, response);
            db.connect();
            out.println("<br />HereDBConnectionDone!!");
            String query = "SELECT adminUsername, adminPassword FROM " +
                    db.getPrefix() + db.getName() + " WHERE adminUsername = '" +
                    adminUsername + "' AND adminPassword = '" + adminPassword + "'";
            Statement stmt = db.createStatement();
            ResultSet result = null;
    if(stmt == null)         out.println("<br />HereDBStmtDone!!");
    
            try {
                result = stmt.executeQuery(query);
                result.beforeFirst();
                out.println("Here!!");
                if(result.next()){
                        HttpSession session = request.getSession(true);
                        session.setMaxInactiveInterval(21*60); // 21 minutes
                        session.setAttribute("JSESSIONID", adminUsername);
    
                        out.println("Correct!!");
                } else {
                    out.println("Invalid!!");
                }
            } catch(SQLException sqle) {
                // TODO SQL Exception
                System.out.println(sqle.getMessage());
            }
        }
    }

signin.jsp JSP file:

    <%--
        Document   : login
        Created on : Jul 19, 2012, 3:36:48 PM
        Author     : mih1406
    --%>
    
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Administration</title>
        </head>
        <body>
            <form action="DoSignIn" method="get" name="adminSignInForm">
                <table>
                    <tr>
                        <td colspan="2">Administration<td>
                            <br />
                    </tr>
                    <tr>
                        <td><label for="adminUsername">Email:</label></td>
                        <td><input type="text" value="${adminUsername}" name="adminUsername" />${emptyEmail}</td>
                    </tr>
    
                    <tr>
                        <td><label for="adminPassword">Password:</label></td>
                        <td><input type="password" value="" name="adminPassword" />${emptyPassword}</td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <input type="checkbox" value="yes" checked="checked" name="persistentCookie" />
                            <label for="persistentCookie">Stay signed in</label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2"><input type="submit" value="Sign in" /></td>
                    </tr>
                </table>
            </form>
        </body>
    </html>