Grails 3 Multiple DataSources

403 views
Skip to first unread message

Christian Oestreich

unread,
Dec 9, 2015, 5:44:02 PM12/9/15
to Grails Dev Discuss
It would appear that when using multiple data sources in grails 3 that the default dataSource element is required.  We currently define our data sources in a plugin and now we have a dangling new element that is unused as all our domain classes point to a named datasource.  In grails 2 we were able to remove the default dataSource block and only provide named data sources.  Was this intentional?  I can not use the below one, two and three data sources unless I define a dataSource.  We can work around this by simply making one and dataSource the same, but this seems redundant.

dataSources:
dataSource:
url: xxxxx
username: xxxxx
password: xxxxx
driverClassName: net.sourceforge.jtds.jdbc.Driver
dialect: org.hibernate.dialect.SQLServerDialect
pooled: true
jmxExport: true
logSql: false
dbCreate: none
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 120000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2
one:
url: xxxxx
username: xxxxx
password: xxxxx
driverClassName: net.sourceforge.jtds.jdbc.Driver
dialect: org.hibernate.dialect.SQLServerDialect
pooled: true
jmxExport: true
logSql: false
dbCreate: none
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 120000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2
two:
url: xxxxx
username: xxxxx
password: xxxxx
driverClassName: net.sourceforge.jtds.jdbc.Driver
dialect: org.hibernate.dialect.SQLServerDialect
pooled: true
jmxExport: true
logSql: false
dbCreate: none
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 120000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2
three:
url: xxxxx
username: xxxxx
password: xxxxx
driverClassName: net.sourceforge.jtds.jdbc.Driver
dialect: org.hibernate.dialect.SQLServerDialect
pooled: true
jmxExport: true
logSql: false
dbCreate: none
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 120000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2

Matthew Treskovich

unread,
Dec 10, 2015, 7:55:25 AM12/10/15
to Grails Dev Discuss
I ran into this issue with Grails 2.x

Rather than having the default datasource point at a production database server, I use an h2 database in memory

 dataSource {
                        dbCreate
= "create-drop"
                        url
= "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
                        driverClassName
= "org.h2.Driver"
               
}

Christian Oestreich

unread,
Dec 10, 2015, 10:49:50 AM12/10/15
to Grails Dev Discuss
Yeah we can do that too.  We are walking through the grails-datasources-plugin looking into another issue where the name using _ and not using _ is causing some weird behavior.  We are trying to also fully grok why the default is required.
Reply all
Reply to author
Forward
0 new messages