hibernate.cfg.xml settings for derby, oracle and h2

GraphHopper – A Java routing engine

karussell ads

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:

  1. 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>

  2. 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>
  3. 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:

  1. Apache Derby (network)
    <dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.4.2.0</version>
    </dependency>
  2. 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>
  3. H2
    <dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.1.102</version>
    </dependency>
About these ads