tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Jacobson <marti...@libero.it>
Subject Re: Connection pooling doesn't work for me ... Help !!
Date Wed, 19 Jun 2002 09:47:19 GMT
info@projektinter.net wrote:

> Hi,
> 
> did anyone of you get any furter?
> 
> thanks anthony 
> 
>>    I've posted a solution see "Generic DataSource Resource Factory
>>Available. JDBC Data Source" 
>>
> 
> and Les Hughes 
> for your tutorials. I still could not succeed.
> 
> Did anyone try to figure out why we do not get a DB-Connection?
> I do not find a point to start form with debugging.
> 
> Rainer


Rainer,

I am in a similar position :-(

If anybody can shed some light on the reasons why it won't work, I'd 
also be VERY grateful!

----------
My set-up:
Mac OS X 10.1.5 - JDK 1.3.1 update 1
DB - mySQL 3.23.49 - mm.MySQL 2.0.14
Tomcat Standalone on ports 80/443 - 4.1.3
Velocity 1.2

----------------------------------------
Here is relevant part of <server.xml>...

<Resource name="jdbc/RadiationDB"
   auth="Container"
   type="javax.sql.DataSource"
/>
<Resource-params name="jdbc/RadiationDB">
   <parameter>
     <name>factory</name>
     <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
   </parameter>
   <parameter>
     <name>maxActive</name>
     <value>100</value>
   </parameter>
   <parameter>
     <name>maxIdle</name>
     <value>30000</value>
   </parameter>
   <parameter>
     <name>maxWait</name>
     <value>100</value>
   </parameter>
   <parameter>
     <name>user</name>
     <value>me</value>
   </parameter>
   <parameter>
     <name>password</name>
     <value>my-password</value>
   </parameter>
   <parameter>
     <name>driverClassName</name>
     <value>org.gjt.mm.mysql.Driver</value>
   </parameter>
   <parameter>
     <name>url</name>
     <value>jdbc:mysql://localhost/radiation</value>
   </parameter>
</Resource-params>

-------------------------------------------------------
Here is the part of <web.xml> where it is referenced...

<resource-ref>
   <description>
     Refers to the jdbc connection pool for this app
   </description>
   <res-ref-name>jdbc/RadiationDB</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>

---------------------------------------------------------

And here is the code that I use to obtain a Connection...


Connection conn=null;
try
{
   javax.naming.Context nctx = new javax.naming.InitialContext();
   if (nctx == null)
     throw new Exception("No Context!");
   DataSource ds = 
(DataSource)nctx.lookup("java:comp/env/jdbc/RadiationDB");
   if (ds == null)
     throw new Exception("No Datasource Found!");
   else
   {
     conn = ds.getConnection();
     if (conn == null)
       throw new Exception("Cant get Connection from DataSource!");
   }
}
catch (Exception e)
{
   log("Error! ", e);
}

-------------------------------------

And here is what I find in the log...

<snip>
2002-06-19 10:58:28 NamingContextListener[/Standalone/localhost/drs]: 
Creating JNDI naming context
2002-06-19 10:58:28 NamingContextListener[/Standalone/localhost/drs]: 
Resource parameters for jdbc/RadiationDB = null
2002-06-19 10:58:28 NamingContextListener[/Standalone/localhost/drs]: 
Adding resource ref jdbc/RadiationDB
2002-06-19 10:58:28 NamingContextListener[/Standalone/localhost/drs]: 
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container}]
2002-06-19 10:58:28 NamingContextListener[/Standalone/localhost/drs]: 
Resource parameters for UserTransaction = null
<snip irrelevant stuff>
2002-06-19 11:00:21 static: Error!
java.sql.SQLException: Cannot load JDBC driver class 'null'
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(Unknown Source)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(Unknown Source)
	at com.terma.martin.drs.StaticPage.handleRequest(Unknown Source)
	at 
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:331)
	at <etc. etc.>

Looking carefully at the logs, it seems that the Resource-params are not 
being processed, so that createDataSource() doesn't know what JDBC 
driver to use. But as far as I can tell, the parameters are all 
correctly specified, so what's going on?

This is beginning to SERIOUSLY p*ss me off!

Martin



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message