Wednesday, January 6, 2010

Switched Grails DataSource from hsqldb to Oracle

Yesterday, I switched the default Grails datasource that grails create-app generates into an Oracle datasource in the following steps:

1. Modify grails-app/conf/DataSource.groovy
2. Add the ojdbc14.jar to /lib
3. Install OracleXE
4. Create a database user and grant privileges

1: DataSource.groovy

dataSource {
pooled = true
driverClassName = "oracle.jdbc.OracleDriver"
}
...
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:oracle:thin:@localhost:1521:XE"
username = "scott"
password = "tiger"
}
}

4: User create script:
conn system/system@xe
drop user scott;
create user scott identified by tiger default tablespace users quota unlimited on users;
grant connect to scott;
grant create any table to scott;
grant create any view to scott;
grant create any sequence to scott;
grant create any index to scott;

-Ben Hidalgo

1 comment:

  1. Hi,
    did nearly the same except the line
    url = "jdbc:oracle:thin:@192.168.2.128:1521:XE"
    to connect to 192.168.2.128 in my network, but I failed with:

    Error 2014-12-22 14:26:23,612 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool.
    Message: E/A-Exception: The Network Adapter could not establish the connection
    Line | Method
    ->> 112 | throwSqlException in oracle.jdbc.driver.DatabaseError
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 146 | throwSqlException in ''
    | 255 | throwSqlException in ''
    | 387 | logon in oracle.jdbc.driver.T4CConnection
    | 414 | . . . . . in oracle.jdbc.driver.PhysicalConnection
    | 165 | in oracle.jdbc.driver.T4CConnection
    | 35 | getConnection . . in oracle.jdbc.driver.T4CDriverExtension
    | 801 | connect in oracle.jdbc.driver.OracleDriver
    | 262 | run . . . . . . . in java.util.concurrent.FutureTask
    | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    | 615 | run . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^ 745 | run in java.lang.Thread

    peter
    dortmund Germany

    ps
    192.168.2.128 is reachable via ping

    ReplyDelete