Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Tomcat and JDBC connection pooling

Reply
Thread Tools

Tomcat and JDBC connection pooling

 
 
Baba
Guest
Posts: n/a
 
      02-16-2004
Hi everybody.

I have learned JDBC and mostly everything I need for the usual database-java
communication, but I was wandering something about the subject of connection
pooling.

I know how to make a servlet that does the pooling for me, but I presume
there is an easier way to achieve it through the Tomcat administration tool.
Unfortunately I do not know how to set that up and use it.

Can anybody give me some help on that subject or point me to an useful link?
thanks.


 
Reply With Quote
 
 
 
 
David Rabinowitz
Guest
Posts: n/a
 
      02-17-2004
I'm sure that a little googling, seaching this newsgroup and the tomcat
docs would have given you this url:
http://jakarta.apache.org/tomcat/tom...les-howto.html

enjoy!

Baba wrote:

> Hi everybody.
>
> I have learned JDBC and mostly everything I need for the usual database-java
> communication, but I was wandering something about the subject of connection
> pooling.
>
> I know how to make a servlet that does the pooling for me, but I presume
> there is an easier way to achieve it through the Tomcat administration tool.
> Unfortunately I do not know how to set that up and use it.
>
> Can anybody give me some help on that subject or point me to an useful link?
> thanks.
>
>

 
Reply With Quote
 
 
 
 
Alan
Guest
Posts: n/a
 
      02-20-2004
Well, I don't know if this can be set up using the console, but the
documentation for Tomcat 5 DB pooling can be found at:

http://jakarta.apache.org/tomcat/tom...les-howto.html

Here are the Tomcat 4 docs:
http://jakarta.apache.org/tomcat/tom...les-howto.html

The administration console can be found at (under default install):
http:localhost:8080/admin

But, you have to set up a user and password in your
<tomcat-install>/conf/tomcat-users.xml file.

You need to add an "admin" role and a user that will be assigned this
role like this (obviously you won't be using "tomcat" as your password):

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="admin"/>
</tomcat-users>

So, I can log in as Tomcat and have admin privs.

This file is a Tomcat 4.1.24 user file... I think they are still the
same... Check out:

Tomcat 5
http://jakarta.apache.org/tomcat/tom...ger-howto.html

Tomcat 4
http://jakarta.apache.org/tomcat/tom...ation%20Access

Hope this helps!

<briggs />


Baba wrote:

> I know how to make a servlet that does the pooling for me, but I presume
> there is an easier way to achieve it through the Tomcat administration tool.
> Unfortunately I do not know how to set that up and use it.


> Can anybody give me some help on that subject or point me to an useful link?
> thanks.

 
Reply With Quote
 
KD
Guest
Posts: n/a
 
      02-23-2004
OK first go to the Tomcat administration tool (See the reply from Alan
below)
..
Click on the mini magnifying glass type of icon to navigate the tree
structure.

Navigate as follows:
Service --> Host (localhost) --> Context (/your_webapp_name) --> Resources

Now click on the data sources link in the tree. In the main frame
window, select the "create new data source" from the drop down that is
labelled "Data Source Actions".

Fill in your normal JDBC stuff. Importantly fill in the following for
the "JNDI Name:" jdbc/abc_def

Click on the Commit Changes button (top right) to save your changes.

Now this is how you would access your data from a servlet or any other
class.

// Obtain our environment naming context
InitialContext initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

// Get a datasource
Datasource myDS = (DataSource)envCtx.lookup("jdbc/abc_def);

From the datasource you get a Connection object and off you go. Your
connections are pooled thanks to Tomcat and its use of the Apache
Commons DBCP project.

Good Luck!







Alan wrote:

> Well, I don't know if this can be set up using the console, but the
> documentation for Tomcat 5 DB pooling can be found at:
>
> http://jakarta.apache.org/tomcat/tom...les-howto.html
>
>
> Here are the Tomcat 4 docs:
> http://jakarta.apache.org/tomcat/tom...les-howto.html
>
>
> The administration console can be found at (under default install):
> http:localhost:8080/admin
>
> But, you have to set up a user and password in your
> <tomcat-install>/conf/tomcat-users.xml file.
>
> You need to add an "admin" role and a user that will be assigned this
> role like this (obviously you won't be using "tomcat" as your password):
>
> <?xml version='1.0' encoding='utf-8'?>
> <tomcat-users>
> <role rolename="admin"/>
> <user username="tomcat" password="tomcat" roles="admin"/>
> </tomcat-users>
>
> So, I can log in as Tomcat and have admin privs.
>
> This file is a Tomcat 4.1.24 user file... I think they are still the
> same... Check out:
>
> Tomcat 5
> http://jakarta.apache.org/tomcat/tom...ger-howto.html
>
> Tomcat 4
> http://jakarta.apache.org/tomcat/tom...ation%20Access
>
>
> Hope this helps!
>
> <briggs />
>
>
> Baba wrote:
>
>> I know how to make a servlet that does the pooling for me, but I presume
>> there is an easier way to achieve it through the Tomcat administration
>> tool.
>> Unfortunately I do not know how to set that up and use it.

>
>
>> Can anybody give me some help on that subject or point me to an useful
>> link?
>> thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JDBC Connection Pooling and Fail-over Alex Collins Java 7 10-30-2009 04:56 PM
pooling the JDBC connection timasmith@hotmail.com Java 1 05-23-2006 12:09 AM
Standard way to setup JDBC connection pooling? Aquila Deus Java 3 02-01-2005 03:13 PM
Tomcat and TCP connection pooling bigbinc Java 0 07-23-2004 12:17 PM
Tomcat Connection pooling with oracle Chandrakanth Java 0 06-07-2004 01:37 PM



Advertisments