I am trying to set up a Connection Pool in Tomcat. We are using an Oracle 9i database. For some reason, when I do the JNDI lookup to get a javax.sql.DataSource object, there is no NamingException thrown or anything, but the DataSource object it returns to me is == null.
I am using Tomcat 4.0, I have the following entry in my
server.xml file:
<Context path="/connfactory" docBase="connfactory" debug="0"
reloadable="true" crossContext="true">
<Resource name="jdbc/finalf" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/finsalf">
<parameter><name>username</name><value>finssys</value></parameter>
<parameter><name>password</name><value>chh9g7</value></parameter>
<parameter><name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>url</name>
<value>jdbc:oracle:thin:@euclid.nfs.nwie.net:1526:finsalf</value>
</parameter>
<parameter><name>validationQuery</name>
<value>select sysdate from dual</value>
</parameter>
<parameter> <name>maxActive</name> <value>20</value> </parameter>
<parameter> <name>maxIdle</name> <value>10</value> </parameter>
<parameter> <name>maxWait</name> <value>-1</value> </parameter>
</ResourceParams>
...other stuff not related to Connection Pooling
</Context>
Then in my
web.xml file I have the following:
<resource-ref>
<description>DataSource corresponding to finsalf</description>
<res-ref-name>jdbc/finsalf</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Then inside a
test JSP I have the following imbedded in a scriptlet:
InitialContext iCtx = new InitialContext();
out.println("getting data source");
Context ctx = (Context) iCtx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("jdbc/finsalf");
out.println("getting connection");
if(ds == null) out.println("DS is Null");
Connection conn = ds.getConnection();
It throws a NullPointerException everytime it tries to call ds.getConnection().
Some things I have tried are: changing the factory in my server.xml to use the simple one that Apache has in their org.apache.common.dbcp package, and using the oracle.jdbc.pool.OracleConnectionPoolDataSource driver instead of the regular oracle.jdbc.driver.OracleDriver. I've tried everything I can think of, so any help would be greatly appreciated.
And rest assured I am not one of those people who forget to award their Duke Dollars! You help, you get the Dukes!!