Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat 4.1.31 Connection Pooling Problem

 
vikrams sawant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am having a problem in creating the Connection Pool for Tomcat. I have created the Data Source through the Admin interface in the Tomcat Server. I am
getting the DataSource Object. But when getting the Connection Object by using getConnection() Method I am getting the following exception .


org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '
org.postgresql.Driver' for connect URL 'jdbc ostgresql//192.168.0.53/xtend', ca
use:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:743)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:518)

i am using postgresql7.3.2 . I have placed the JDBC Driver jar file in the
server\common\lib directory . From the error message it seems that Tomcat is not able to load the corresponding jar file of the JDBC Driver. Can any one help me in solving the problem

Content of the server.xml file regarding the Context is as follows

<Context className="org.apache.catalina.core.StandardContext" cachingAllowed="true" charsetMapperClass="org.apache.catalina.util.CharsetMapper" cookies="true" crossContext="false" debug="0" docBase="F:\jakarta-tomcat-4.1.31\webapps\alienrevolt" mapperClass="org.apache.catalina.core.StandardContextMapper" path="/alienrevolt" privileged="false" reloadable="false" swallowOutput="false" useNaming="true" workDir="work\Standalone\localhost\alienrevolt" wrapperClass="org.apache.catalina.core.StandardWrapper">
<Resource name="jdbc/alienrevolt" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/alienrevolt">
<parameter>
<name>url</name>
<value>jdbc ostgresql//192.168.0.53/xtend</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>postgres</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</Context>
 
Ray Stojonic
Ranch Hand
Posts: 326
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jar containing the driver should be in the /WEB-INF/lib of your application, or common/lib of tomcat.

If that doesn't work, it may be that jar's internal structure is incorrect.
Rename it to zip, open and make sure things are where they should be. Finally, double check the fully qualified class name.
 
vikrams sawant
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per your suggestion i have made the necessary changes of renaming the file but still there is some error when i am calling the servlet

org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.postgresql.Driver', cause:
java.lang.ClassNotFoundException: org.postgresql.Driver
at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClas
sLoader.java:945)
at org.apache.catalina.loader.StandardClassLoader.loadClass(StandardClas
sLoader.java:810)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:730)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:518)

well the good thing i am noticing is that error message is diff from the previous one.

Thanks Very mech
for the Reply ,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic