Configuring Grails DB Connection Pool

945 views
Skip to first unread message

Robert Fischer

unread,
Sep 29, 2008, 2:34:21 PM9/29/08
to groo...@googlegroups.com
Okay, so by using the kill -3 trick to get a dump of the thread state, I'm finding that they're all
blocking while going after a database connection. I've only got 6 connections, and I'm perfectly OK
with Grails going up a power of 10 or so on that number of connections, but I can't find where to
configure that.

Any tips?

~~ Robert.

Ted Naleid

unread,
Sep 29, 2008, 5:17:26 PM9/29/08
to groo...@googlegroups.com
Depends on which DB you're using and whether you're using a JNDI
connection or doing the configuration in your DataSource.groovy file.
Here's an example DataSource.groovy snippet for mysql that specifies
connections:

dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
maxActive = 30
initialSize = 0
//loggingSql = true
}

It's been a while since I needed to mess with this, but I think that
the properties that are in the dataSource stanza are anything that are
normally in the tomcat context XML

Alternatively, you should be able to reference a JNDI connection and
configure that connection (and the number of connections it allows) in
your webserver's container (normally in a "context" snippet of xml).

-Ted

Robert Fischer

unread,
Sep 29, 2008, 5:20:03 PM9/29/08
to groo...@googlegroups.com
I'm just doing it via the DataSource.groovy

I've dropped some code into the BootStrap.groovy to grab the "dataSource" bean out of the context
and do some configuration on it -- is it equivalent to setting properties in DataSource.groovy?

~~ Robert.

Ted Naleid

unread,
Sep 29, 2008, 5:23:50 PM9/29/08
to groo...@googlegroups.com
I think it should be. The only negative I can think of for that is
that it isn't "environment aware" and that you'd manually need to code
different settings in for each of the environments you'd run in (so if
dev has a different pool limit than a QA environment or over
production) and that the datasource config has those environment
sections already built in.

For testing to see if it works, I think that should be OK (assuming
hibernate is able to pick up those differences and doesn't have the
pool size already established, something I'm not 100% positive about).

-Ted

Reply all
Reply to author
Forward
0 new messages