Reputation: 12389
I need to configure a datasource to use in grails.
I created file scripts/_Events.groovy
with content bellow:
eventConfigureTomcat = {tomcat ->
print "Applying changes to tomcat configuration..."
}
The question is: how can I use tomcat
instance to configure a datasource in deployment time?
Note1: if there's a solution using something like server.xml
file, it's great too.
Note2: tomcat
object is a instance of org.apache.catalina.startup.Tomcat
Tks.
Upvotes: 0
Views: 2234
Reputation: 12389
Solved!
I putted this in config.groovy
:
grails.naming.entries = [
'myDS': [
type: "javax.sql.DataSource",
auth: "Container",
driverClassName: "foo.myDriver",
maxActive: "8",
maxIdle: "4",
url: "my_jdbc_url",
username: "user",
password: "pass"
]
]
See also.
Upvotes: 1
Reputation: 41208
I assume you don't want to hard-code your production datasource. You can use Grails externalized configuration capability or a JNDI datasource defined in your deployed Tomcat context.
Upvotes: 1