• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Regarding Connection pool

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

The advantage of using connection pool is get the open connection......use it and return it to the pool once the request is processed so that other request acquires that connection and uses it.

I have a doubt...........

We generally acquire the connection and close it in finally like



here does it mean that we are closing that acquired connection or does it mean that we are returning it to the pool but connection is not closed?

I was told in an interview that connection should not be closed ...........i dont understand this.
 
Ranch Hand
Posts: 40
Eclipse IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, and the other advantage is:
- The overhead of opening and closing the connection is avoided, which could be a huge performance hit.

You may read below page and get some clarity:
http://www.javaranch.com/journal/200601/JDBCConnectionPooling.html

Now coming to your doubt:

Whenever you close a connection, when connection pooling is implemented, the connection always returns to connection pool.
So, you must answer like whenever we do connection.close(), below two things can happen:
- If connection is obtained from the pool, connection is returned to the pool.
- Otherwise it is simply closed.
 
Thanuja Vishwanath
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

So, you must answer like whenever we do connection.close(), below two things can happen:
- If connection is obtained from the pool, connection is returned to the pool. (this is the case when connection pool is implemented?)
- Otherwise it is simply closed. (this is the case when connection pool is not implemented? is that so?)

correct me if iam wrong and also when the connection will be closed in connection pooling?. say i have 3 connections in a pool and all the request to my application uses it. now all the request has been processed. there is no more request to be processed. so my last request uses a connection and returns to the pool. now i dont have any request to process. so what will happen ie. when the connection will actually be closed.
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so what will happen ie. when the connection will actually be closed.


When the application stops.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, if you are using a custom connection pool, there will probably be methods to purge/close/destroy the physical connections.

For Example, purgeCache in OracleConnectionCacheManager
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i have implemented the connection pooling in my web Application (For the First time) . the application is for online application form which may active for specific days. i don't know how many user will access this form at a time. My question is it that sufficient or i have to make any modifications?

i have three classes 1]DBConnector : used for creating connection pool and makes a connection available from the pool.
2]connection : used to connect to connection pool.
3]appform : from where connection request is send to connection pool via connection class.

code snip in reverse i.e. from appform to dbconnector.




Method connectDB in connection class



connection pooling class




will this is sufficient for any no of users


 
Police line, do not cross. Well, this tiny ad can go through:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic