posted 21 years ago
I am trying to use a connection pool to retrieve
data from a database. I have succeeded in putting InitialContext, DataSource, Statement,
ResultSet in "one servlet". And I am able to display the output in the browser. It means that the table is created in the database, the connection pool is properly configured, DataSource is referenced in the web.xml, and mapping in the web.xml has been taken care of.
I ran into problem when I tried to put
IntialContext and DataSource in one class
(DBConnection.java) that specializes in providing Connection object (conn). And another class
(VerificationServlet.java) with Statement and
ResultSet in it references the provided Connection object. (DBConnection.java and VerificationServlet.java are in a package 'cptest'.)
The error message I got is
"java.lang.NullPointerException at
cptest.VerificationServlet.doGet(VerificationServlet.java:25)
and the 25th line of the VerificationServlet is
Statement stmt = conn.createStatement();
I am lost. I do not know what went wrong.
DBConnection.java
VerificationServlet.java
[ July 11, 2003: Message edited by: JiaPei Jen ]