hibernate hsql

In this section, you will learn HSQLDB connection using Hibernate.

hibernate hsql

hibernate hsql

In this section, you will learn HSQLDB connection using Hibernate.

HSQL

HSQL stands for Hyper Structured Query Language. HSQL is the structured query language of HSQLDB(Hyper Structured Query Language Database) which is a relational database system written in Java. It has a JDBC driver . HSQLDB is recognized for its small size ,flexibility,speed and its ability to execute completely or partly in memory.

For connecting to HSQLDB , you need to download  hsqldb-2.2.8.jar file from here.

The hibernate.cfg.xml should have following configuration for using HSQLDB :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:mem:anky</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

<!-- Echo all executed SQL to stdout --> 
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup 
<property name="hbm2ddl.auto">create</property>

<mapping resource="net/roseindia/Worker.hbm.xml"/>
</session-factory>
</hibernate-configuration>

NOTE :Except the above configuration all the codes are same for using Hibernate to connect to HSQL database.

For complete tutorial on Hibernate 4 click here .