I am making my first steps with Grails and try to create a hello world application with an Oracle Database 12c.
Unfortunately the tutorial documentation on the datab
Hibernate as of 2.0.1 (Grails 2.0.1) supported a property "dialect". As shown below. Presume there's a similar property still for newer versions of Hibernate.
File .../grails-app/conf/DataSource.groovy
// Global data source settings
// Note that these global properties values are composited with
// the environment-specific properties under "environments"
dataSource {
pooled = true
driverClassName = "oracle.jdbc.OracleDriver"
...
// Required for function with Oracle 12c and above.
// Not required for Oracle 11.2 and below. For the present works with both.
// Specifying Oracle 10 dialect is sufficient.
// Oracle 12c specific dialect support is not available for Hibernate 2.0.1.
// Works with either ojdbc7 or ojdbc8 jars.
dialect = org.hibernate.dialect.Oracle10gDialect
}
Applying the "dialect" property was sufficient to run older code against both Oracle 11g, 12c. It bought time for code migration to newer versions and dependencies.
yes this will be OK for meanwhile. But there are details missing. I'll post detailed instructions as soon as i get to the office. Actually there is a sample for mySql somewhere on the grails site, and from it it's pretty clear how to make same for an oracle DB.
I just have created a new app and compared it with myne for oracle 11g. Here it is:
./build.gradle, add following line to "dependencies" section:
runtime "com.oracle:ojdbc14:10.2.0.3.0"
./grails-app/conf/application.yml, add following to "hibernate" section:
jdbc: use_get_generated_keys: true
dataSource: pooled: true jmxExport: true driverClassName: oracle.jdbc.OracleDriver username: YOURUSERNAME password: yoursecret
environments: development: dataSource: dbCreate: create url: jdbc:oracle:thin:@somehost.net:1521:YOURORAINSTANCE test: dataSource: dbCreate: update url: jdbc:oracle:thin:@somehost.net:1521:YOURORAINSTANCE production: dataSource: dbCreate: update url: jdbc:oracle:thin:@somehost.net:1521:YOURORAINSTANCE
And the Hibernate dialect for Oracle you have is pretty old one, I think you'd better remove it, without specifying it explicitly all works fine.
download ojdbc7.jar from http://www.oracle.com/technetwork/database/features/jdbc/jdbc-drivers-12c-download-1958347.html
create a <myapp>/lib folder in the main folder of your application (lib folder was removed from Grails 3)
copy ojdbc7.jar to lib folder
add this line to the <myapp>/build.gradle file
dependencies{
(...)
runtime fileTree(dir: 'lib', include: '*.jar')
(...)
}
hibernate:
(...)
jdbc:
use_get_generated_keys: true
dataSource:
pooled: true
jmxExport: true
driverClassName: oracle.jdbc.OracleDriver
username: DBUSERNAME
password: dbpassword
environments:
development:
dataSource:
dbCreate: create
url: jdbc:oracle:thin:@localhost.net:1521:dbname
test:
dataSource:
dbCreate: update
url: jdbc:oracle:thin:@localhost.net:1521:dbname
production:
dataSource:
dbCreate: update
url: jdbc:oracle:thin:@locaLhost.net:1521:dbname
You can get the JDBC driver through this maven command.
mvn install:install-file \ -Dfile=/lib/ojdbc7.jar \ -DgroupId=com.oracle \ -DartifactId=ojdbc7 \ -Dversion=12.1.0.1 \ -Dpackaging=jar \ -DgeneratePom=true