From: Alex <ale...@go...> - 2003-03-06 08:38:34
|
i didn't find any other mailing list to post my questin to, so, i post it here, it may be off topic... i wanna use Proxool 0.7 into tomcat, but i can't understand how does it work. i've configured web.xml for my context to load ServletConfigurator at context startup. 1. when i request a connection, using: Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); try { connection = DriverManager.getConnection("proxool.example" + ":com.mysql.jdbc.Driver" + ":jdbc:mysql://192.168.17.17:3306/testdb?user=tomcat&password=tomcat&autoRec onnect=true"); ............. , a pool is being created and it return a connection. So, the connection pool is being created at the first DriverManager.getConnection(....) request ? If the pool named 'example' doesn't exists, it creates a new one ? 2. When i run again that code, it doesn't create a new pool, it uses the 'example' pool and returns a connection from that pool. How does proxool knows that 'example' pool exists ? (maybe this is a pretty stupid question, but i don't get it) 3. Is there any way to reference the pool object ? because i don't wanna use: Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); try { connection = DriverManager.getConnection("proxool.example" + ":com.mysql.jdbc.Driver" + ":jdbc:mysql://192.168.17.17:3306/testdb?user=tomcat&password=tomcat&autoRec onnect=true"); every time i request a new connection. Is there any way to use something like this: a) create a new pool at context startup b) get connections from that pool like this: pool.getConnection(poolName[,...]); c) shutdown that pool at context shutdown ? Thanks in advance... Alex |
From: Bill H. <bi...@lo...> - 2003-03-06 09:39:12
|
Hi Alex, On Thu, 2003-03-06 at 08:38, Alex wrote: > i didn't find any other mailing list to post my questin to, so, i post it > here, it may be off topic... Not at all. But you're right, there should be a proxool-user list. I'll create one. > i've configured web.xml for my context to load ServletConfigurator at > context startup. That's a good start. > 1. > when i request a connection, using: > Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); > try { > connection = DriverManager.getConnection("proxool.example" + > ":com.mysql.jdbc.Driver" + > > ":jdbc:mysql://192.168.17.17:3306/testdb?user=tomcat&password=tomcat&autoRec > onnect=true"); > ............. > , a pool is being created and it return a connection. > > So, the connection pool is being created at the first > DriverManager.getConnection(....) request ? > If the pool named 'example' doesn't exists, it creates a new one ? Yes. This is how it works. Each pool is uniquely identified by its alias. If the alias hasn't been used before it will create this pool for you. > 2. > When i run again that code, it doesn't create a new pool, it uses the > 'example' pool and returns a connection from that pool. Oh good. That's what it's supposed to do :) > How does proxool knows that 'example' pool exists ? Because it keeps a track of what pools are registered and reuses them. > 3. Is there any way to reference the pool object ? > because i don't wanna use: > Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); > try { > connection = DriverManager.getConnection("proxool.example" + > ":com.mysql.jdbc.Driver" + > > ":jdbc:mysql://192.168.17.17:3306/testdb?user=tomcat&password=tomcat&autoRec > onnect=true"); > every time i request a new connection. Yep, sure there is. The documentation doesn't seem to tell you though :) I'll fix that today. Basically, all you have to do is use "proxool.alias". So in your example: connection = DriverManager.getConnection("proxool.example"); will connect to the same database and reuse the same properties. > Is there any way to use something like this: > a) create a new pool at context startup Absolutley. I recommend it. Look at: http://proxool.sourceforge.net/servlets.html for examples of how to setup the ServletConfigurator to register the pool(s) based on an XML file. Or, if for some reason you don't like that, you could do it programmatically: http://proxool.sourceforge.net/configure.html > b) get connections from that pool like this: > pool.getConnection(poolName[,...]); No. You have to go through the ProxoolDriver. It's for your benefit really; you want as few dependencies on Proxool in your code as possible. Using the JDBC Driver makes it easier for you to switch to another pool if you want (we hope you won't!). > c) shutdown that pool at context shutdown That's a very wise thing to do. Again, see http://proxool.sourceforge.net/servlets.html and look at Installation notes at the bottom, number 1. You need to call ProxoolFacade.shutdown when you context shuts down (perhaps in a Servlet destroy() method?). But, if you use ServletConfigurator and you don't override the autoShutdown init parameter (defaults to true), then that will happen automatically. Feel free to post back here if you have any further questions - although I will be creating a proxool-user list in the next 24 hours. Cheers, -- Bill Horsman Proxool http://proxool.sourceforge.net ICQ: 119577180 |