|
Hi, I have connection pool set up in my grails application. I know that if I use "def dataSource" in a service class, I can use it to create a new groovy sql object and run sql queries by hand. Is it possible to use the same dataSource object or something else during run time to get the # of connections in the datasource pool? Thanks, José
|
|
If is possible to access the BasicDataSource created by Grails, you can use the getNumActive method. I searched but not found this answer.
Regards, Sérgio
On Mon, Jun 4, 2012 at 2:19 PM, José Cedeño <[hidden email]> wrote:
|
|
Sergio,
Thanks for the response. I found a different way of doing it, but it accomplishes the same: Sql sql = new Sql(dataSource) sql.dataSource.targetDataSource.connectionPool._pool.size() Thanks, José On Tuesday, June 5, 2012 at 9:16 AM, Sergio Michels wrote:
|
|
You have to be careful with calls like these - they're very provider-specific. The DataSource interface only has a few methods so anything like these that access useful information will have different method names (or not even exist) with different pool implementations. If you decide later to switch to Tomcat Pool or C3P0 you will likely see errors on these calls.
Burt
|
|
Burt,
Thanks for the heads up. If I need to figure out the number of connections in the pool in the future, I will use more generic code like you specify. I just wanted to verify and test that the connection pooling was working with grails. Thanks, José On Tuesday, June 5, 2012 at 10:13 AM, burtbeckwith wrote:
|
| Powered by Nabble | Edit this page |
