Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / January 2005

Tip: Looking for answers? Try searching our database.

Tomcat database connection pool doesn't work. Please help!

Thread view: 
correro - 22 Dec 2003 06:14 GMT
I tried to set up a database connection pool by following exactly the instructions in Tomcat 5 JNDI Datasource HOW-TO. But I got the following exception:

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver
       at java.sql.DriverManager.getDriver(DriverManager.java:243)
       at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
.. ...

Can someone tell me why? Here's some info about my environment:

OS: Windows 2000 Professional
J2SE: 1.4.2
Tomcat: 5.0.16
Database: MySQL 4.0.13
DB Driver: org.gjt.mm.mysql.Driver; com.mysql.jdbc.Driver

By the way, when I query the database using a conventional Connection created with DriverManager, it works.
David Rabinowitz - 22 Dec 2003 09:01 GMT
OKay, saw that after your second post.

Where do you put the jar of the JDBC driver ? if you are using the built
in DBCP DataSource and you put your JDBC driver at the WEB-INF/lib
directory, than perhaps you have a class loading problems. See
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/class-loader-howto.html

David

> I tried to set up a database connection pool by following exactly the instructions in Tomcat 5 JNDI Datasource HOW-TO. But I got the following exception:
>
[quoted text clipped - 13 lines]
>
> By the way, when I query the database using a conventional Connection created with DriverManager, it works.
Serpico2003@hotmail.com - 11 Jan 2004 22:00 GMT
> OKay, saw that after your second post.
>
[quoted text clipped - 22 lines]
> >
> > By the way, when I query the database using a conventional Connection created with DriverManager, it works.

I have exactly the same problem ( Cannot create JDBC driver of class
'' for connect to URL 'null')  running Tomcat 4.1.29 & mysql-3.23.58
on debian  (also tried  tomcat 4.0.16 & mysql-4.0)  , and  JDBC driver
mysql-connector-java-2.0.14-bin.jar which i put in
$TOMCAT_HOME/common/lib
( i also tried the latest mysql jdbc driver )

Using the conventional connecting via DriverManager works though .

i've been searching for a couple days on the groups but still no luck
.

plz help :)
Xavier Tarrago - 12 Jan 2004 07:52 GMT
See
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.h
tml#Database%20Connection%20Pool%20(DBCP)%20Configurations


> > OKay, saw that after your second post.
> >
[quoted text clipped - 6 lines]
> >
> > > I tried to set up a database connection pool by following exactly the instructions in Tomcat 5 JNDI Datasource HOW-TO. But I got the following
exception:

> > > org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause:
> > > java.sql.SQLException: No suitable driver
> > >         at java.sql.DriverManager.getDriver(DriverManager.java:243)
> > >         at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.jav
a:743)
> > > ... ...
> > >
[quoted text clipped - 21 lines]
>
> plz help :)
Serpico2003@hotmail.com - 11 Jan 2004 22:00 GMT
> OKay, saw that after your second post.
>
[quoted text clipped - 22 lines]
> >
> > By the way, when I query the database using a conventional Connection created with DriverManager, it works.

I have exactly the same problem ( Cannot create JDBC driver of class
'' for connect to URL 'null')  running Tomcat 4.1.29 & mysql-3.23.58
on debian  (also tried  tomcat 4.0.16 & mysql-4.0)  , and  JDBC driver
mysql-connector-java-2.0.14-bin.jar which i put in
$TOMCAT_HOME/common/lib
( i also tried the latest mysql jdbc driver )

Using the conventional connecting via DriverManager works though .

i've been searching for a couple days on the groups but still no luck
.

plz help :)
Serpico2003@hotmail.com - 11 Jan 2004 22:05 GMT
> OKay, saw that after your second post.
>
[quoted text clipped - 22 lines]
> >
> > By the way, when I query the database using a conventional Connection created with DriverManager, it works.

Hi guyz,   I have the same problem  using tomcat 4.1.29/mysql-3.23.58
and JDBC driver mysql-connector-java-2.0.14-bin.jar ( put in
$TOMCAT_HOME/common/lib )
and the test xml files ( server.xml and web.xml) from tomcat-page . I
vee been searching for  a day or 2  but  i cant figure out what the
heck  s going on .
Using the conventional connection approach (DriverManager) works
though.

any help would be appreciated
steepyirl - 03 Jan 2005 20:56 GMT
In general, you must make sure to have the libs:

commons-collections.jar
commons-dbcp-<version>.jar
commons-logging-api.jar
commons-pool-<version>.jar (a version compatible with the dbcp version
you're using)
naming-common.jar
naming-factory.jar
naming-resources.jar
plus any libs for your DB driver

all of these should be in your ${TOMCAT_HOME}/common/lib folder and
NOWHERE ELSE.

This will make DBCP work with Tomcat 4.1.x but NOT with Tomat 5,
apparently. Please let me know if anyone figures out how to make this
work in Tomcat 5. Thanks!!!
Daniel Rohe - 04 Jan 2005 08:39 GMT
Why should connection pooling not work in Tomcat 5 when you have all the
required libs in your <tomcat_home>/common/lib folder? The connection
pooling should work always, you must configure the datasource in your
serverside configuration file. I've made a small help document in German for
me, where the configuration of a resource is explained. Here I use the test
database in MySQL. You can find it under [1]. The configuration must be in
the <Context> of your web application.

[1] http://www.stud.tu-ilmenau.de/~daro-in/texts/text01.html

Regards,
Daniel

> In general, you must make sure to have the libs:
>
[quoted text clipped - 14 lines]
> apparently. Please let me know if anyone figures out how to make this
> work in Tomcat 5. Thanks!!!
steepyirl - 05 Jan 2005 15:44 GMT
That's a very good question. I had a fully functional configuration
using Tomcat 4.1.30, which worked flawlessly. Then, I moved the *same*
configuration to my Tomcat 5 instance, moved the code, moved
configuration, moved required libraries into all the places where they
were supposed to be, and.... Tomcat cannot instantiate the data source.
It appears that it's unable to load the resource parameters, since it's
trying to instantiate a data source of class '' and url 'null'.
However, the rest of the application does load correctly.

By the way, out of curiosity, are you using JRE 1.5 or JDK 1.4.2 with
compat libraries?

Thanks!

> Why should connection pooling not work in Tomcat 5 when you have all the
> required libs in your <tomcat_home>/common/lib folder? The connection

> pooling should work always, you must configure the datasource in your

> serverside configuration file. I've made a small help document in German for
> me, where the configuration of a resource is explained. Here I use the test
[quoted text clipped - 24 lines]
> > apparently. Please let me know if anyone figures out how to make this
> > work in Tomcat 5. Thanks!!!
Daniel Rohe - 05 Jan 2005 22:33 GMT
Currently I have Tomcat 5.0 with JDK 1.4.2_06 on WinXP machine running. On
my machine there is a web application with MySQL database, Hibernate ORM and
Struts frontend and it works perfect. I've only copied the MySQL JDBC driver
to <tomcat_home>/common/lib. the commons-dpcp is already there.
Are you using Tomcat 5.5 or Tomcat 5.0?

Here is my configuration of the jUDDI application, maybe this helps
<Resource name="jdbc/juddiDB" auth="Container"
          type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/juddiDB">
 <parameter>
  <name>factory</name>
  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
 </parameter>

 <parameter>
  <name>maxActive</name>
  <value>10</value>
 </parameter>
 <parameter>
  <name>maxIdle</name>
  <value>5</value>
 </parameter>
 <parameter>
  <name>maxWait</name>
  <value>10000</value>
 </parameter>

 <parameter>
  <name>username</name>
  <value>juddi</value>
 </parameter>
 <parameter>
  <name>password</name>
  <value>********</value>
 </parameter>
 <parameter>
  <name>driverClassName</name>
  <value>com.mysql.jdbc.Driver</value>
 </parameter>

 <parameter>
  <name>url</name>
  <value>jdbc:mysql://localhost:3306/juddi?autoReconnect=true</value>
 </parameter>
 <parameter>
  <name>validationQuery</name>
  <value>select count(*) from PUBLISHER</value>
 </parameter>

</ResourceParams>

> That's a very good question. I had a fully functional configuration
> using Tomcat 4.1.30, which worked flawlessly. Then, I moved the *same*
[quoted text clipped - 49 lines]
> this
>> > work in Tomcat 5. Thanks!!!
steepyirl - 12 Jan 2005 17:07 GMT
Looks good. I'm connecting to two SQL Server DBs through dbcp. I have
no specialized bean container or anything like that, and I'm using
Tomcat 5.5. My resource configuration is almost identical to yours.
Thanks!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.