Solved

connection ooling with tomcat

Posted on 2004-08-19
7
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

707 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