• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Connection Pool

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi...

Me and my colleague got into an argument lately. I'm relatively new to using connection pool. She says that in a connection pool connection objects are created on each request. Is that true?

If true, when is it destoryed? Would'nt it be a burden on the server?

Can any give me a link or explain how exactly a connection pool works..!

Thanks in advance

P-R-E-S-I
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


She says that in a connection pool connection objects are created on each request. Is that true?


Well, it depends on which connection pool implementation she is talking about but generally no. Connections in the connection pool will generally be reused, rather than destroyed and recreated. When you write a piece of code that calls an open method on a connection while using a connection pool, the connecion pool will probably get an already open but currently free connection from the pool and use that, rather than explicitly creating a new conneciton. Simmilaraly, if you call the close method on the connection it will be freed up to the pool, rather than being explicitly closed. If you want to see how a connection pool does this, you might want to download the source of an open source connection pool implementation and have a look.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only occassions I have seen connections being created is when the pool is initialized.

However paul says that it'd be "generally true". Paul, could you tell me when we could actually think of opening a connection everytime a hit is made to the pool.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Re-read my post. I don't say that it is generally true that connections are created for each request made to the pool, I say the opposite.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic