Paul,
Add this to the context for each application that needs the database.
<ResourceLink name="jdbc/OscarsDB" global="jdbc/OscarsDB"
type="javax.sql.DataSource"/>
Doug Parsons
www.parsonstechnical.com
----- Original Message -----
From: "Paul Mahoney" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Monday, March 15, 2004 2:28 PM
Subject: Problem using JNDI/DBCP to get DataSouce
My code looks up a DataSource instance using JNDI. It get an instance but
all the fields are default or null values. When I try to get a connection I
get the error
Exception: Cannot create JDBC driver of class '' for connect URL 'null'
Its like it finds my configured resource, but the server has not initialised
it...
I have followed the How-To's and gone through it all countless times. I
can't get tomcat to give me any debug or extra logging to help me track the
cause. Below are the gory details for those that can help me (please!!!)
Version - Tomcat 4.1.24
Web.xml (last part as to DTD)
-----------------------------
<resource-ref>
<description>Reference to factory javax.sql.DataSource to create
connection instances for OSCARS</description>
<res-ref-name>jdbc/OscarsDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
------------------------------
Server.xml
-------------------------------
<GlobalNamingResources>
<Environment name="simpleValue" override="true" type="java.lang.Integer"
value="30"/>
<Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase" scope="Shareable"
type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container" name="jdbc/OscarsDB" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/OscarsDB">
<parameter>
<name>url</name>
<value>jdbc:informix-sqli://oscar1.travel2.com:1420/oscars:INFORMIXSERVER=os
cars_dbsrv</value>
</parameter>
<parameter>
<name>password</name>
<value>notreal</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.informix.jdbc.IfxDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>trip</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
---------------------------------------
Code extract
---------------------------------------
if (dataSource == null)
{
try
{
synchronized (this)
{
if (dataSource == null)
{
Context initContext = new InitialContext ();
Context envContext = (Context) initContext.lookup
("java:comp/env");
dataSource = (DataSource) envContext.lookup ("jdbc/OscarsDB");
}
}
}
catch (NamingException ne)
{
// wrap it up in an SQLException to keep calling code simple
SQLException se = new SQLException ("JNDI Data Source lookup
failed");
se.initCause (ne);
throw se;
}
}
try
{
connection = dataSource.getConnection ();
}
catch (SQLException se)
{
throw se;
}
return connection;
}
-------------------------------
End of message, thank you for your time
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]