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!