aspose file tools
The moose likes JDBC and the fly likes Connection handling in large web apps Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Connection handling in large web apps" Watch "Connection handling in large web apps" New topic
Author

Connection handling in large web apps

Ahmed Yehia M
Greenhorn

Joined: Dec 05, 2008
Posts: 2
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 ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26168
    
  66

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ahmed Yehia M
Greenhorn

Joined: Dec 05, 2008
Posts: 2
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 26168
    
  66

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.
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Connection handling in large web apps
 
Similar Threads
Can start and stop tomcat through FTP??
Calling functions in JSp
Help required on weblogic connection pool properties
Calling functions in JSp
Closing The connection (Database)