Where answers come from

Some pages can ask a language model questions. Set this up once; your choice is remembered in this browser for the whole site.

Model source
Use another source instead
You sign in on OpenRouter; it gives this page a key for your account.

Grails Datasource, legacy database, and you

Originally published .

Any one out there trying to work with Groovy, Grails, and legacy databases?

Well, I am and I thought I’d share with you my final dataSource configuration. I’m using a legacy database that drove an Apache + mod_perl web site that had a MySQL 3.x database. The Groovy/Grails project I’m working on will interact with that data (right now as a read-only service) and here’s the final dataSource definition I ended up using for our first beta.


import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration

/**

 * This project is driven off of Legacy data.

 * Use update to prevent wiping old tables...

 * much of the data is accessed using JPA classes generated by

 * the Hibernate3 reverse engineer tool.

 ********************************************************************/

 dataSource {

  configClass = GrailsAnnotationConfiguration.class

  dbCreate = "update"

  dialect= org.hibernate.dialect.MySQLMyISAMDialect // or perhaps MySQL5Dialect

  pooled = false

 }

 environments {

  development {

   dataSource {

    driverClassName = "com.mysql.jdbc.Driver"

    url = "jdbc:mysql://localhost:3306/legacy?zeroDateTimeBehavior=convertToNull"

    username = "legacy"

    password = "legacy"

   }

  }

  test {

   dataSource {

    driverClassName = "com.mysql.jdbc.Driver"

    url = "jdbc:mysql://localhost:3306/legacy?zeroDateTimeBehavior=convertToNull"

    username = "legacy"

    password = "legacy"

   }

  }

  production {

   dataSource {

    jndiName = "java:/LegacyDS"

   }

  }

}

The LAMP stack was upgraded to use MySQL 5 recently so we can set up our new projects using the setting dialect= org.hibernate.dialect.MySQLInnoDBDialect which will give us the ability to use actual foreign key relationships. That’s a big deal if you are a LAMP developer. I suppose that in short order I will be a Grails, Linux, Apache, MySQL developer… a GLAM developer… ah… no… lets not call it that.

BTW: I deploy to a JBoss Application server in production which manages the DataSources in a legacy-ds.xml file under /usr/local/jboss/server/default/deploy that’s why my production dataSource uses the jndi lookup.

Explore the map · Browse by topic and date