Skip to content

Instantly share code, notes, and snippets.

@abadongutierrez
Last active November 10, 2017 19:28
Show Gist options
  • Save abadongutierrez/4665610 to your computer and use it in GitHub Desktop.
Save abadongutierrez/4665610 to your computer and use it in GitHub Desktop.
Grails: DataSource.groovy for MySQL
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "****"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
properties {
maxActive = 50
maxIdle = 25
minIdle = 5
initialSize = 5
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
maxWait = 10000
ValidationQuery = 'select 1'
}
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "none" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:mysql://localhost/db_dev?useOldAliasMetadataBehavior=true"
}
}
test {
dataSource {
dbCreate = "none"
url = "jdbc:mysql://localhost/db_test?useOldAliasMetadataBehavior=true"
}
}
production {
dataSource {
...
}
}
}
@Chaguala
Copy link

dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/yourDb"
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "xxxx"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/yourDb"
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "xxxx"
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment