Organizational Research By

Surprising Reserch Topic

Configure HSQLDB in java web application


Pre-Requisite :

JDK 1.6 (Separate download for JDK 1.5 is available)

hsqldb.jar (Included in hsqldb-2.2.8.zip. Can be downloaded from here )

Spring JDBC 3.1 Jar

How to configure in Spring :
To configure HSQLDB, we need to add  configuration details in applicationContext.xml with other bean information.

http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:jd="http://www.springframework.org/schema/jdbc"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/jdbc
      " rel="nofollow" target="_blank">http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
 
 
 
      
      
 

 

Here schema.sql contains the detail of DB that needs to be created by HSQLDB.

CREATE TABLE JBT_MEM(ID VARCHAR(5),PAN_NUMBER  VARCHAR(10),ADDRESS VARCHAR(40),CITY VARCHAR(35),STATE VARCHAR(2),PINCODE integer);
 

To populate the newly created DB test-data.sql script would be required.

insert into JBT_MEM values('20','AABBAABB','Address','NY','AB',23500);
insert into JBT_MEM values('20','BGDBCBDB','Address','City','State',23500);
Above created datasource can be used in combination of jdbctemplate and Hibernate. This datasource can directly be injected in dao layer to work with jdbctemplate.

 
  
 

To work with hibernate one more configuration would be required

 
     
     
       
             org.hsqldb.jdbcDriver
             true
       

     

  
  
 

 

This session factory can now be injected in Dao layer.


  
 
asked Sep 1, 2015 in spring framework by rajesh
0 votes
33 views



Related Hot Questions



Government Jobs Opening


...