Skip to content

Grails on Oracle

April 15, 2013

Here are my experiences from getting a brand new Grails 2.2.1 app running on a legacy Oracle database (11gR2).

  1. Get runtime dependency “com.oracle:ojdbc6:$version”. You won’t find this on mvnrepository.com because of licensing issues.
  2. In DataSource.groovy
    1. set driverClassName to “oracle.jdbc.driver.OracleDriver”
    2. set your username and password for the DB.
    3. set dialect to “org.hibernate.dialect.Oracle10gDialect”
    4. If your DB has multiple schemas, you must specify “hibernate.default_schema”. NOTE: I tried not setting this variable and instead using the GORM static mapping “schema” attribute of the table operation, but that did not have the desired effect.
    5. Lastly, set the JDBC thin url: “jdbc:oracle:thin:@hostname:port:SID”

That’s all that was involved in setting up so that Grails could connect to the Oracle DB. The next major task involved configuring domain classes (GORM) to operate on legacy database design. I had to set the “id” field and generators on every domain class, and referencing the sequence generators in Oracle. A clear majority of the effort was spent on configuring GORM to work with Grails unfriendly conventions.

Advertisements

From → Groovy

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: