aspose file tools*
The moose likes Struts and the fly likes Maintaining database connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Maintaining database connections" Watch "Maintaining database connections" New topic
Author

Maintaining database connections

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
In my application having around 10 actions i want to connect to database in all actions.

i am using a class DBConnector whose instance will make a connection with the database specified.
i want to create an instance of this class only once in the scope of my application. that is only one connection for all clients irrespective of the session.

where should i instantiate this class to accomplish my requirement. In ActionServlet or RequestDispatcher? which method should i override to get this.


SCJP 1.4
Jan Groth
Ranch Hand

Joined: Feb 03, 2004
Posts: 456
write it as a singleton at let it instantiate itself :-)

so you can access it from whereever you want...

regards,
jan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maintaining database connections
 
Similar Threads
Problem accessing class variable
Database connections in Servlet
Object Instantiation
Java DAO pattern: singleton and threadsafe?
J2EE/Struts 1.1 pattern tips