I just ran my practice servlet, which calls two separate classes
DBConnector and RecordObj, and received this nullPointer exception.

java.lang.NullPointerException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at DBConnector.(DBConnector.java:39)
        at DBConnector.getInstance(DBConnector.java:58)
        at JohnServlet.doPost(JohnServlet.java:15)
        at javax.servlet.http.HttpServlet.service
(HttpServlet.java:747)
        at javax.servlet.http.HttpServlet.service
(HttpServlet.java:840)
        at com.sun.web.core.ServletWrapper.handleRequest
(ServletWrapper.java:155)
        at com.sun.web.core.InvokerServlet.service
(InvokerServlet.java:168)
        at javax.servlet.http.HttpServlet.service
(HttpServlet.java:840)
        at com.sun.web.core.ServletWrapper.handleRequest
(ServletWrapper.java:155)
        at com.sun.web.core.Context.handleRequest(Context.java:414)
        at com.sun.web.server.ConnectionHandler.run
(ConnectionHandler.java:139)

DBConnector is using a properties file to access the driver and the
url strings for making the db connection. The nullpointer comes at:

    username = props.getProperty("username");
    password = props.getProperty("password");
    url = props.getProperty("url");
    driver = props.getProperty("driver");

    try
    {
      Class.forName(driver);
      connection = DriverManager.getConnection
              (url, username, password);
    }

Is there something about servlets that interferes with accessing a
properties file, or is my problem more fundamental?

I know I probably should set the db settings in the configuration xml
file, but I am trying to incremental about learning to use servlets
and jsp's.

I am reusing the db code, so I believe it should have no problems
loading the properties.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to