• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

postgres pool with Tomcat 4.1

 
adrian kiwi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every one!
I try to use the connection pool feature from Tomcat.
I followed the instruction from the jakarta web-site:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html, but it didn't works.
I have jbuilderx with this configuration:
1) Personalized server8080.xml file:
............
<Context debug="0" docBase="......">
<Resource name="jdbc/postgres" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/postgres">
<parameter>
<name>factory</name>
<value>
org.apache.commons.dbcp.BasicDataSourceFactory
</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc ostgresql://127.0.0.1:5432/mydb</value>;
</parameter>
<parameter>
<name>username</name>
<value>myuser</value>
</parameter>
<parameter>
<name>password</name>
<value>mypasswd</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>
</Context>
</Host>
....................
2) web.xml
<resource-ref>
<description>postgreSQL Datasource</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3) commons.jar, coomons-dbcp.jar, commons-collection were addes in
c:\JBuilderX\thirdparty\jakarta-tomcat-4.1.27-LE-jdk14\common\lib\
4) I have pg73jdbc3.jar file puted in project library
5) I'm using postgres 7.3.5
6) java code:
try{
InitialContext initCtx = new InitialContext();
if(initCtx == null )
throw new Exception("Boom - No Context");
Context ctx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)ctx.lookup("jdbc/postgres");
if (ds != null) {
Connection conn = ds.getConnection();
if(conn != null) {
conn.close();
}
}
}
catch(Exception e) {
e.printStackTrace();
}
When I run the java code I receive:
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver
...............
Thanks,
Adrian
[ February 25, 2004: Message edited by: adrian kiwi ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly adrian, welcome to the Ranch.
Secondly, as you can see in your post, HTML markup doesn't work and only makes your post less readable. You can use the 'edit' feature to go reformat your post without the HTML markup. Hint: UBB tags can be used to format code, quote, bold and so on...
Lastly, since this is more a Tomcat setup question than a JDBC question, I'm moving this topic to the Tomcat forum where the Tomcat-savvy hang out. Please make your edits and continue any discussion there.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
4) I have pg73jdbc3.jar file puted in project library

This also needs to be in the common/lib directory of tomcat.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic