Freitag, 27. November 2009

Turn JBoss AS into a HSQLDB server

Developing with Seam its nice to have easy access to a test DB.
Hypersonic SQL fits the need nicely.
Best of all - its distributed with JBoss AS already.

Before now, I used the supplied hsqldb-ds.xml and modified it to my needs,
inlcuding enabling the hsqldb over tcp mbean.

But it was painful to create a new dummy Seam project with the JBoss Tools
just to switch the datasource file later.

Then it occured to me:

Why not just copy the mbean part into a new service.xml file ?

Then I can use a persisting hsqldb server in tcp mode and create new
Seam projects with the real datasource from the start.

So without further ado here is the contents of my new hsqldb-service.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=HypersonicDB">
<attribute name="Port">9001</attribute>
<attribute name="BindAddress">${jboss.bind.address} </attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
<attribute name="No_system_exit">true</attribute>
</mbean>
</server>



Update:
Use 127.0.0.1 instead of ${jboss.bind.address}.
Makes it easier to create ds.xml files for and makes it more secure.


<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=HypersonicDB">
<attribute name="Port">9001</attribute>
<attribute name="BindAddress">127.0.0.1</attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
<attribute name="No_system_exit">true</attribute>
</mbean>
</server>

Keine Kommentare: