Posted by: bgopi | January 21, 2014

Visualizing in memory database(embedded) HSQL in spring 3.x

Below is the configuration need to be placed in your context.xml

<bean id=”dataSource” class=”org.springframework.jdbc.datasource.DriverManagerDataSource”>
<property name=”driverClassName” value=”org.hsqldb.jdbc.JDBCDriver”/>
<property name=”url” value=”jdbc:hsqldb:mem:testdb”/>
<property name=”username” value=”sa”/>
<property name=”password” value=””/>
</bean>

<jdbc:initialize-database data-source=”dataSource”>
<jdbc:script location=”classpath:schema.sql”/>
<jdbc:script location=”classpath:data-sql.sql”/>
</jdbc:initialize-database>

To visualize in memory database, you can use below  commands in terminal:

DatabaseManager – AWT UI:

java -cp <path_to_this_jar>/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManager –url jdbc:hsqldb:mem:testdb

E.g., java -cp ~/.m2/repository/org/hsqldb/hsqldb/2.3.1/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManager –url jdbc:hsqldb:mem:testdb

DatabaseManagerSwing – Swing UI:

java -cp <path_to_this_jar>/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManagerSwing –url jdbc:hsqldb:mem:testdb

e.g., java -cp ~/.m2/repository/org/hsqldb/hsqldb/2.3.1/hsqldb-2.3.1.jar org.hsqldb.util.DatabaseManagerSwing –url jdbc:hsqldb:mem:testdb

or you can embed below code in any java class:

org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
“–url”, “jdbc:hsqldb:mem:testdb”
});

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: