From: Bill H. <bi...@lo...> - 2003-11-20 19:47:29
|
By: zyzgy ( Jason Oh ) shutting down proxool 2003-11-20 15:31 hello, i have a trivial question. just started using proxool and am not sure about how to shutdown the proxool connection pool. i can close all the connections manually (conn.close()), but don't know if it is up to me to shutdown the proxool pool. i've noticed that there is a shutdown hook which starts when the application exits--does this take care of connection pool cleanup at application exit? thanks for your help! By: billhorsman ( Bill Horsman ) RE: shutting down proxool 2003-11-20 15:41 Hi Jason, It depends in what environment you are running Proxool... if it's an application running in it's own JVM and you're using JDK 1.3 or later then the ShutdownHooks will do exactly what you want. JDK 1.2 doesn't support ShutdownHooks, in which case you should call ProxoolFacade.shutdown() explicitly. If you are running Proxool in something like a servlet container (e.g. JBoss, Resin) then you need to explicitly shutdown too - otherwise if you redeploy you end up with two instances of Proxool (the JVM doesn't call the shutdown hooks on a redeploy). In that case, you also need to call shutdown() explicitly. Normally in a servlet's destroy() method. Alternatively, use the ServletConfigurator and it will do it for you. Just to make sure you are using the pool correctly: you call conn.close() after every database action right? You shouldn't leave them open until the application is shutting down - that is what Proxool does for you. Cheers, Bill Horsman By: zyzgy ( Jason Oh ) RE: shutting down proxool 2003-11-20 16:03 hi bill, thanks for your prompt response! yes, i'm currently running jdk1.4.2 in a testing environment (command-line) and will have to migrate everything to a servlet container soon (tomcat4). i call conn.close() immediately after every db call currently. so, in the context of a servlet container, you mention that shutdown() must be called explicitly. i use the DriverManager to getConnection() and use the proxool PropertyConfigurator to initialize proxool. on which object must i invoke shutdown() once i move to tomcat? also, i'm thinking that i will have to use transactions as part of my app. do you have any suggestions/ideas with respect to the best way to use transactions in concert with proxool? thanks again for your help, jason By: billhorsman ( Bill Horsman ) RE: shutting down proxool 2003-11-20 16:32 Hi Jason, Take a look here: http://proxool.sourceforge.net/servlets.html It tells you how to use the ServletConfigurator to automatically configure Proxool using a properties file. The benefits of which are: 1) No Proxool code in your app, just some lines in web.xml 2) ServletConfigurator will automatically call ProxoolFacade.shutdown() in its destroy() method. In answer to your specific question about calling shutdown(). You use ProxoolFacade.shutdown(). It's a static method, so no object needed. As far as transactions go, Proxool treats them transparently. That is, you use them exactly as you would with no connection pool: open the connection at the start of the transaction, close the connection at the end of the transaction. Cheers, Bill --- This forum entry is being posted on this list because the old forum is being deleted. |