Changing Grails datasource to use PostgreSQL

18 01 2009

My database name is erace (not to have to type the actual name of the database each time I invoke psql).

  1. Get JDBC Driver for PostgreSQL
  2. Drop the jar in $project_home/lib
  3. Change $project_home/conf/DataSource.groovy to this:
    dataSource {
    	pooled = true
    	driverClassName = "org.postgresql.Driver"
    	username = "erace"
    	password = "passw0rd"
    }
    hibernate {
        cache.use_second_level_cache=true
        cache.use_query_cache=true
        cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
    }
    
    environments {
    	development {
    		dataSource {
    			dbCreate = "update" // one of 'create', 'create-drop','update'
    			url = "jdbc:postgresql:erace"
    		}
    	}
    	test {
    		dataSource {
    			dbCreate = "update"
    			url = "jdbc:postgresql:erace"
    		}
    	}
    	production {
    		dataSource {
    			dbCreate = "update"
    			url = "jdbc:postgresql:erace"
    		}
    	}
    }
            

Docs:
Grails Ref Guide on DataSource

Advertisement

Actions

Information

4 responses

11 10 2011
binpath

Excelent post!

15 06 2011
erdal

thank you so much, very useful sharing

11 10 2010
Jack

Many thanks for the post, it is really useful !

26 06 2009
Taras Matyashovsky

Thanks for the post.
Brief and useful.

Leave a Reply

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

Gravatar
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 )

Connecting to %s




Follow

Get every new post delivered to your Inbox.