Results 1 to 1 of 1
- 11-05-2007, 01:59 PM #1Member
- Join Date
- Nov 2007
- Rep Power
Loading a connectionpool with IIS-servletexec
I have a web-application running servlets using ServletExec and IIS on a windows computer.
I also have a connectionpool (primrose) to provide me with connections to the database.
My question is when and how do you best load the connectionpool?
At the current time I have a class called DBBroker who handles the connections. This class has three methods (getConnection, closeConnection and loadPool). getConnection returns a connection from the pool and an exception is thrown is the pool is not loaded. closeConnection returns the connection to the pool. loadPool creates the pool.
Each time a servlet is run i need to do this:
DBBroker dbb = new DBBroker();
Connection conn = dbb.getConnection();
The problem is ofcourse that the connectionPool is not loaded the first time I start up my application. So I basicly have a try-catch within the getConnection method and if a catch appears then the loadPool() method is runned. This causes the application to get an error the first time a servlet is called and the next times it works perfectly. So to work around this i added in the catch in the getConnection() method below the loadPool line a new attempt to get the connection. This makes everything work perfectly.
But despite that everything do work it feels like a weird way to do it.
Is it a way to get the loadPool() method to be run when you start the IIS? Or is there another smart way to load the pool without doing try-catches to see if it already has been loaded?
Thanks in advance for all your helpfull answers!
- By jimm1 in forum Advanced JavaReplies: 6Last Post: 06-23-2008, 08:31 PM
- By Thulasiraman in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 10:33 AM
- By shaungoater in forum Java 2DReplies: 2Last Post: 01-09-2008, 09:14 AM
- By marco in forum Java AppletsReplies: 3Last Post: 08-14-2007, 11:32 PM