my dog learned polymorphism
The moose likes Servlets and the fly likes Configuring connection pooling in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Configuring connection pooling in tomcat" Watch "Configuring connection pooling in tomcat" New topic

Configuring connection pooling in tomcat

Glenny Dsilva
Ranch Hand

Joined: May 09, 2005
Posts: 42
I want to configure connection pooling in tomcat 5.0

Gone through the eg. give in the url below

After configuring server.xml and web.xml

The code is below

package foo;

import javax.naming.*;
import javax.sql.*;
import java.sql.*;

public class DBTest {

String foo = "Not Connected";
int bar = -1;

public void init() {
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");

DataSource ds =

if (ds != null) {
Connection conn = ds.getConnection();

if(conn != null) {
foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst =
"select id, foo, bar from testdata");
if( {
}catch(Exception e) {

public String getFoo() { return foo; }
public int getBar() { return bar;}

I am geting "-1 Not Connected"

pls. help.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

It's best to keep one topic in one thread.
In your other thread, I gave you a link to the 5.5 JNDI documentation.
Now I can see you're using 5.0.
Your link points to the 4.1 configuration page.

Here is the link to the 5.0 documentation.

Also, this is a servlets forum.
There is a forum just for Tomcat on this site.
If you ask your configuration questions there, you are much more likely to have it seen by someone who has dealt with the same issue.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Glenny Dsilva
Ranch Hand

Joined: May 09, 2005
Posts: 42
Sorry, i'll post it in the right place next time....
I agree. Here's the link:
subject: Configuring connection pooling in tomcat
jQuery in Action, 3rd edition