Monday, January 16, 2006

Persistence layer Hibernate

We have a website on struts, we have installed a database, now we want to connect the webapp with the database.
You can do this simply using java code but what if you want to change from database vendor.
Then there is a lot of recoding as all these vendors use there own version of SQL.

With hibernate, changing database type, is changing the three lines of code that setup the database connection in the hibernate.cfg.xml file.
This is the example code to setup hibernate and postgreSQL.

pgsql-de-komma
jdbc:postgresql://localhost/deKomma
postgres
org.postgresql.Driver
org.hibernate.dialect.PostgreSQLDialect
*******

This is not a hibernate tutorial, I just want to show how I set it up.
If you have any question, please do not hesitate to contact me.

No comments: