Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

hibernate.cfg.xml Settings for Derby, Oracle and H2

DZone's Guide to

hibernate.cfg.xml Settings for Derby, Oracle and H2

· Database Zone
Free Resource

Learn how to move from MongoDB to Couchbase Server for consistent high performance in distributed environments at any scale.

It took me some time to collect the hibernate.cfg.xml data which is necessary for Derby, Oracle and H2. So here are the default settings for those databases:

Apache Derby (network)

You start the network server and specify the following options in the script:

Linux: DERBY_OPTS=”-Dij.driver=org.apache.derby.jdbc.ClientDriver -Dij.protocol=jdbc:derby://localhost:1527/ -Dij.user=admin -Dij.password=admin”Windows: set DERBY_OPTS=”-Dij.driver=org.apache.derby.jdbc.ClientDriver -Dij.protocol=jdbc:derby://localhost:1527/ -Dij.user=admin -Dij.password=admin”
<property name=”hibernate.connection.driver_class”>org.apache.derby.jdbc.ClientDriver</property><property name=”hibernate.connection.url”>jdbc:derby://localhost:1527/databaseName;create=true</property><property name=”hibernate.connection.username”>admin</property><property name=”hibernate.connection.password”>admin</property><!– no schema necessary –><property name=”hibernate.dialect”>org.hibernate.dialect.DerbyDialect</property>

Oracle(Thin) 

<property name=”hibernate.connection.driver_class”>oracle.jdbc.driver.OracleDriver</property><property name=”hibernate.connection.url”>jdbc:oracle:thin:@host:1521:databaseName</property><property name=”hibernate.connection.username”>YOURSCHEMA</property><property name=”hibernate.connection.password”>YOURPASSWORD</property><property name=”hibernate.default_schema”>YOURSCHEMA</property><property name=”hibernate.dialect”>org.hibernate.dialect.OracleDialect</property>

H2

<property name=”hibernate.connection.driver_class”>org.h2.Driver</property><property name=”hibernate.connection.url”>jdbc:h2:path\databaseName</property><property name=”hibernate.connection.username”>sa</property><property name=”hibernate.connection.password”></property><property name=”hibernate.default_schema”>PUBLIC</property><property name=”hibernate.dialect”>org.hibernate.dialect.H2Dialect</property>

To make it complete here are the Maven settings for the databases:

Apache Derby (network)

<dependency><groupId>org.apache.derby</groupId><artifactId>derbyclient</artifactId><version>10.4.2.0</version></dependency>

Oracle (thin)

No public version is available but you could install the jar file into your local repository or into an archiva repository via:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.1.0.7.0 -Dpackaging=jar -Dfile=/path/to/file 
<dependency><groupId>com.oracle</groupId><artifactId>ojdbc6</artifactId><version>11.1.0.7.0</version></dependency>

H2

Want to deliver a whole new level of customer experience? Learn how to make your move from MongoDB to Couchbase Server.

Topics:
java ,sql ,frameworks ,persistence

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}