The moose likes JDBC and the fly likes How to organize the connection through out the application process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to organize the connection through out the application process" Watch "How to organize the connection through out the application process" New topic
Author

How to organize the connection through out the application process

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
Hi,


Here in my application is using the following steps for a process.
- Login
- Search
- Update
- Logout

In those above steps, Login, Search, and Update actions are touching to database everytime. In each time, Im getting the Context object, I think this is a bad approach. When I hit the login, I need to get the connection object and use that for rest of the actions(search and update).

So can we organize the single connection through out the application? And where do we need to close the Context object?


Thanks,
Kumar
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30924
    
158

Kumar,
Most people have a connection pool and don't manage connections at the user level. Then the application can ask for a connection whenever it needs in rather than passing it around.


[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
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
Here one thing, I forgot to mention that the context is for LDAP not for DB. I know how to make manage connection using for DB but I don't know how to use it for LDAP.
Kalyan Ram
Greenhorn

Joined: Dec 29, 2003
Posts: 14
Sudhakar Kumar wrote:Here one thing, I forgot to mention that the context is for LDAP not for DB. I know how to make manage connection using for DB but I don't know how to use it for LDAP.

errr since you are still dealing with j.l.Object, maybe you could use Commons Pool - http://commons.apache.org/pool/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to organize the connection through out the application process