File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Connection managment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Reply locked New topic

Connection managment

John Burton

Joined: Mar 26, 2012
Posts: 5
I am working on an application where the main concern is speed. They are using jsf and the existing controllers are filled with multiple database calls with a connection that is being passed from call to call. It's very quick, but a complete mess with many of the same calls rewritten on every page.

I have introduced a dao layer for better maintainability and reuse, but it's just not as fast. The problem is that my connections are on a method level and creating a db2 connection is expensive. I need to create a connection and use it for all the daos in a page view. What is the best way to do that?

I was thinking of creating a DAOManager and in it's constructor having it create a connection and use the DAOMannager to get each dao and pass it the connection the constructor such as

I have not seen this documented anywhere so I am wondering if there is a better way to do it? We are not using any sort of persistence framework, just straight sql calls.

Thanks for your help!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3152

Please CarefullyChooseOneForum. As it looks more of a design related issue, lets continue the discussion here.

Mohamed Sanaulla | My Blog
I agree. Here's the link:
subject: Connection managment
It's not a secret anymore!