Search code examples
grailsgroovyjndigrails-orm

Is it possible to use a JNDI dataSource read only in Grails?


I need to add a JNDI datasource from a legacy database to my Grails (1.2.2) application. So far, the resource is added to my Tomcat (5.5) and DataSource.groovy contains:

development {
    dataSource {
      jndiName = "jdbc/lrc_legacy_db"
    }
}

I also created some domain objects mapping the different tables to comfortably load and handle data from the DB with GORM. But I now want to assure, that every connection to this DB is really read-only. My biggest concern here is the dbCreate- property and the automatic database manipulation through GORM and the GORM classes.

Is it enough to just skip dbCreate? How do I assure that the database will only be read and never ever manipulated in any way?


Solution

  • You should use the validate option for dbCreate.

    EDIT: The documentation is quite a bit different than when I first posted this answer so the link doesn't quite get you to where the validate option is explained. A quick find will get you to the right spot.