?
Solved

connection ooling with tomcat

Posted on 2004-08-19
7
Medium Priority
?
182 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 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

764 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