SQL Zone is brought to you in partnership with:

Hacking on GraphHopper - a Java road routing engine. Peter has posted 62 posts at DZone. You can read more from them at their website. View Full User Profile

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

06.10.2009
| 65228 views |
  • submit to reddit

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

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.1.102</version>
</dependency>

 From http://karussell.wordpress.com/

3
Your rating: None Average: 3 (3 votes)
Published at DZone with permission of its author, Peter Karussell.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Marcus Bosten replied on Wed, 2009/06/10 - 4:04am

Dear all, take care that h2 Dialect in Hibernate is buggy (See http://www.h2database.com/h2.pdf). Further, you can start the H2 database in different modes (embeded and Server). Best Regards, Marcus

Thomas Mueller replied on Wed, 2009/06/10 - 5:38am

The H2 Hibernate dialect (BOOLEAN versus BIT data type) was recently fixed in Hibernate, but I don't think it is already released. If it affects you, you could use for example the HSQLDialect or the PostgreSQLDialect.

Marcs Linuxs replied on Thu, 2009/06/11 - 7:49pm

@peter: thanks for the article. The more I read about hibernate, the more I think I need to relearn it . The point ? Is harder without it. I really appreciate configuration samples and advices like this. Keep up the good work.

Warning: fanboism (see [horror story] below) and bad english ahead. Stop reading it right know if it upsets you. You have been warned :-).

About H2: I never heard before about H2 (man, so many OSS projects). Went to h2database.com , like , whatever, another db . Then I saw H2 site. I'm very impressed! Looks like the guys follow the advice: Always try to do the right thing.

The site is simple and to the point. Tutorial, docs, well written (with polished screenshots!)

Download H2. run. It just work. From the browser. Even with linux (second class for many projects out there). Bonus point for the use of notification area (small H2 icon next to clock) in ubuntu, nice touch. The H2 console is awesome, very well done, works in the browser (and looks like a desktop app).

The only problem is that now it hurts to look at other project's pages (sf.net, talking to you) :-) Please , H2 guys , share with us your strategies, motivations, philosophies, so that we can make a better web. Many thanks for such a nice project. Very inspirational.

/fanboism

[horror story] -- where I work (for government, don't ask) the people still can't do DB normalization, the projects are done with _one_ jsp page (or worst php) and talk about OOP is like talk about disease. I'm very frustrated because even the young developers find very hard anything more complex than procedural languages. It is sad.

Some times I think that maybe the computers are becoming _really hard_ to (average people) understand. The singularity is near? Given some more years, and nobody will be able to really program them? This is worrisome.

Thats why I'm so happy with H2 developers (and java/linux developers) , it shows that there is hope :-). Please share knowledge as much as possible, so we can leave this rock before is too late (man, so many space science articles lately).

Cheers, marcolinux

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.