Annyce Davis

Davis Technology Consulting

  • Home
  • About Me
  • Blog
  • Courses
  • Newsletter

Configuring MySQL with Grails

June 5, 2009 by Annyce Davis

Here are the steps to configure your Grails application to work with a MySQL database.

  1. Put the MySQL Connector J driver class in the lib folder of your Groovy App.
  2. In the DataSource.groovy file remove the default HSQLDB information and replace with MySQL specific configuration. (Sample file using a database called ‘books’ is shown below)

dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = "admin"
}

hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
}

// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop"
url = "jdbc:mysql://localhost:3306/books"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/books"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/books"
}
}
}

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Reddit (Opens in new window) Reddit

Related

Filed Under: Grails Tagged With: MySQL

Follow Me

  • Bluesky

Categories

  • Android (60)
  • Career (5)
  • Communication (4)
  • Flutter (1)
  • Git (4)
  • Gradle (4)
  • Grails (23)
  • iOS (1)
  • Java (8)
  • JavaScript (6)
  • Kotlin (17)
  • Life (5)
  • Public Speaking (26)
  • Revenue (2)
  • RxJava (1)
  • Software Development (13)
  • Twitter (3)
  • Uncategorized (11)
  • Video Course (5)

Follow Me

  • Bluesky

Copyright © 2025 · All Rights Reserved · Log in