I am trying to use an Oracle database to a Grails project. I work with the command line tool.
So far:
I have put the ojdb6 into a lib directory I had to create myself, at the root of my application
I modified application.yml as follow:
dataSource: pooled: true jmxExport: true driverClassName: oracle.jdbc.OracleDriver username: usrname password: pwd environments: development: dataSource: dbCreate: create-drop url: jdbc:oracle:thin:@//url:port/db test: dataSource: dbCreate: update url: jdbc:oracle:thin:@//url:port/db production: dataSource: dbCreate: update url: jdbc:oracle:thin:@//url:port/db properties: jmxEnabled: true initialSize: 5 maxActive: 50 minIdle: 5 maxIdle: 25 maxWait: 10000 maxAge: 600000 timeBetweenEvictionRunsMillis: 5000 minEvictableIdleTimeMillis: 60000 validationQuery: SELECT 1 validationQueryTimeout: 3 validationInterval: 15000 testOnBorrow: true testWhileIdle: true testOnReturn: false jdbcInterceptors: ConnectionState defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
I also created a domain-class with an Integer attribute, just to give it a try.
However, it doesn't seem to work. I get a huge error message that doesn't even fit in my command window. When I use --stacktrace, the first message is "Failed to start server".
I've been trying to solve this problem for three days, any idea/comment will be welcome. Thank you kindly.
Side note: everythink works perfectly when I use the default database, not changing anything in the configuration.
Try below, it should work. if it doesn't post the stack trace. below snippet worked for me.
Add dependency: runtime 'oracle:ojdbc6:11.2.0.4.0'
Changes in application.yml:
environments:
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
development:
dataSource:
dbCreate: validate
url: jdbc:oracle:thin:@xxxx:1521:xx
driverClassName: oracle.jdbc.OracleDriver
dialect: org.hibernate.dialect.Oracle10gDialect
username: "XXXXXX"
password: "XXXXXX"
properties:
***: **
***: **
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
On Oracle DB the validation statement (property validationQuery: SELECT 1) should be something like:
"SELECT 1 FROM DUAL"
Oracle does not support SELECT 1
I was having a similar issue recently and in my case it was due to using a format that did not match with my Oracle database configuration; this is what I found:
If your database uses an SID , your url should be in the form:
url: jdbc:oracle:thin:@url:port:sid
,
eg url: jdbc:oracle:thin:@192.168.1.44:1521:testdb
If your database uses a Service Name , your url should be in the form:
url: jdbc:oracle:thin:@//url:port/servicename
eg url: jdbc:oracle:thin:@//localhost:1521/testdb
Hope this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.