Solved

connection ooling with tomcat

Posted on 2004-08-19
7
152 Views
Last Modified: 2013-11-24
Hi,  I understand that to get connection pooling to work with tomcat I need to modify some configuration files.

I have docs on how to do that , so thats fine.

My question is to do with whether the methods used to call the getConnection object should be synchronized or not.

Currently the getConnection method is called using synchronized methods. so that only one method can be dealing with it at one time.

Am i correct in htinking, once connection pooling is enabled, the methods which call cetConnection need not be synchronized?

The second part iof my question is what will happen if say, I have configured 15 connections to be in the pool and there comes a time when 16 are needed?  will the last method to request a connection just have to wait its turn?

If so, how will i be able to test if it is working?
0
Comment
Question by:rosshind
  • 5
  • 2
7 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11843673
Hi rosshind,

> Am i correct in htinking, once connection pooling is enabled, the
> methods which call cetConnection need not be synchronized?
>

I would keep the getConnection method synchronized.

> The second part iof my question is what will happen if say, I have
> configured 15 connections to be in the pool and there comes a time when
> 16 are needed?  will the last method to request a connection just have
> to wait its turn?

It depends on the algorithm used with the conneciton pool. Many servers woudl just wait for a connection to be available before proceeding, others would just create a new connection after the limit is reached.

Regards
0
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 11843696
> > Am i correct in htinking, once connection pooling is enabled, the
> > methods which call cetConnection need not be synchronized?
> >
>
> I would keep the getConnection method synchronized.

I mean, if you call getConnection this should not be synchronized, but the implementation getConnection() of the pool is probably synchronized.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11843713
> If so, how will i be able to test if it is working?

Just have a for loop that creates 16 connections, perform some long data processing and see the time it takes for each one.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:rosshind
ID: 11843907
I have a load of DAO methods which currently are synchronized,

what I'll do is remove synchronization form them,  and make the static method which wraps the getConnection method synchronized.

Is that what you would suggest?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11844073
I think you could avoid synchronizing the call to getConnection since the container's implementation of the connection pool should be already synchronized. Maybe you want to take a look here to see how a conneciton pool is implemented: http://www.webdevelopersjournal.com/columns/connection_pool.html
0
 

Author Comment

by:rosshind
ID: 11851368
Thanks a million,

thats a real help,  I have it all working now.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11851524
Thak you for accepting, glad I was of help :)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars challenge 6 64
Spring Controller - inheritance in request parameter 3 38
countPairs challenge 7 58
Java Loop 4 3
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now