Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JSP's, Servlets and Database

Posted on 2001-06-07
3
Medium Priority
?
284 Views
Last Modified: 2013-11-24
When developing a Web application that uses databases in either JSP's or Servlets is it good practice to open the connection to the database in every Servlet or JSP that requires a database connection or would it be more appropriate to manage all database access via a bean ?

If it is best to manage all database access via a bean would it be appropriate to store this bean in the session object (so that it is created for each user session) or would it be more appropriate to store it in the application object ?  My concern here is related to the overhead of opening many connections to a database.

I would be grateful for all advice offered regarding this.

Thanks in advance

John
0
Comment
Question by:johnclarke
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Expert Comment

by:chrisos
ID: 6163103
The method I use to to use a bean that manages a connection pool for the database.

The bean resides at an aplication level, so the pool is always available.

By using a pool, you only have the overhead required to create the initial connections and any additional connections when the pool runs out.  In return you get good performance from your requests when the pool can service the request.

Regards,

Chrisos
0
 

Accepted Solution

by:
dwhitake earned 200 total points
ID: 6166282
A connection pool is definitly the best way to go.  It makes db access simpler by keeping track of all your connections for you.  There us a free connection pool available at:  http://www.javaexchange.com

I have used it before and it works really well.  You can also specify parameters to it that let you customize the initSize and maxSize of your connection pool, so you don't have to worry about too few or too many connections open at one time.

Hope this helps,
David
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6777984
johnclarke--->  You logged in recently, but did not update/finalize your open questions.  Please do.

If you've been helped, please accept the expert comment which helped you to grade and close it.  If you need help splitting points between multiple experts, comment with detail.

I will post this in all your open questions and monitor them for closure.  Please check the HELP DESK link on the left for site-related information on the Question/Answer process, Guidelines and Member Agreement.

Expert input is always welcome to determine the fair outcome of this question in the event johnclarke does not respond.

Thanks all,

Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question