Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection Pool

 
Pendurthi prashanth
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
Prashant Jain
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic