This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am working on a web application an i want to implement the Connection Pooling. And i wat to store my database details in a seperate properties file instead of placing them in Context.xml.
I had done some modification to Connection Pool Class for getting details from configuration file.
my all queries are in a normal java class. I am trying to get connection in a init() method of a servlet so that i can get connection at any time.
My servlet's Init method has the following code
if i use another servlet then i can get the connection object. But through a normal java class i wat to get a connection object. but how can i get the connection object.
Please help me in this issue...
You'll need to make it available to your class somehow. For normal ConnectionPools this would be done via the DataSource bound in JNDI. If you are not doing something simmilar your normal class will need to configure its own instance of your pool.
We faced a similar problem as we had to use ConnectionPooling for core java programs. We solved it by writing our own implementation of connection pooling.
The concept is to create a static Connection pool object for each database at startup. During the initialization itself the connections are established. Then the getConnection method can be accessed throughout the application.
They say you have to be the first, the best or different. I say, is it too much to ask for all three.