• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Connection handling in large web apps

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy
I want to know what is the most efficient way to handle DB connections in a large and high traffic web app.

Currently I m using a DriverManager connection to execute DB queries and updates.

This *single* connection was created in my context listener and I m using it through out the application for all components to use.

I still haven't published the web app to the internet yet so I haven't fully tested it out..

I want to know what are the pros and cons of using my current method and would I get connection pooling? also if there is a better way to handle this issue.

my code looks like:


[ December 05, 2008: Message edited by: Eric Damps ]
 
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
This would not give you connection pooling - you need multiple connections for that. Connection pooling is critical for large apps. See DBCP for an open source one.
 
Ahmed Yehia M
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne,
Probably I'd be using DataSource instead.

I've got another question about my current implementation. Can this single connection be used by more than one user at a time concurrently or is it synchronized? note that I'm actually establishing a connection to the DB before bounding the Conn. object into the context, and later just getting the Conn. object and use it to query DB.
[ December 06, 2008: Message edited by: Eric Damps ]
 
Jeanne Boyarsky
author & internet detective
Posts: 39343
755
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Eric Damps:
Can this single connection be used by more than one user at a time concurrently or is it synchronized?


It looks like multiple users can try to use it at the same time. That wouldn't go well for them though.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!