wood burning stoves
The moose likes Servlets and the fly likes connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "connection pooling" Watch "connection pooling" New topic

connection pooling

Sanjaykar Gurram

Joined: May 05, 2008
Posts: 22
Hi all

take this scenario..

i am having maximum 100 connections(initial 50, increment=5,max=100) configured in my connection pool.
in the application runtime 100 users are already using the connections.
now the App. Server is not allowed to create another.

now my ques. is.. 101th user has come in, and he wants to do an urgent updation in the DB and he needs a connection.He cant wait b'coz
he is in a time bound application.in time he has to update his work, or else it is waste.

now how can the 101th user can get the connection?
what the application server is going to do in this scenario?
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

The server doesn't know or care about request priority. It works on a first come, first served policy. It can't interrupt any current connections because that would break whatever the other users are doing and would leave the database in an unknown state. So it must wait for a connection and if this urgent request is the next in line, it will give it to him.

If you want to provide a priority-based connection system you will have to manage separate connection pools, reserving 1 or more connections for those high priority cases.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

A well-written application will hold connections for the shortest duration possible, so no one should have to wait very long for a connection. How long does your application hold onto connections?

[Asking smart questions] [About Bear] [Books by Bear]
Sanjaykar Gurram

Joined: May 05, 2008
Posts: 22
Hi All

Thanks for your time.

Actually why i posted this in this forum is, i was asked this question by an interviewer. He told me this scenario and expected my answer.

yes, ofcourse a user doenst need a connection for a longer duration.
might be the interviewer wants to test me for a good answer.

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Well yeah, usually.
I agree. Here's the link: http://aspose.com/file-tools
subject: connection pooling
It's not a secret anymore!