Solved

connection ooling with tomcat

Posted on 2004-08-19
7
153 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 80
java. non-English characters encoding problem. intellij idea 3 74
Java / Linux and Regular Expressions 11 70
map related example 6 35
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

910 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

20 Experts available now in Live!

Get 1:1 Help Now