HSQLDB:Tips and Tricks

From Apache OpenOffice Wiki
Revision as of 07:58, 18 September 2006 by Frank Schoenheit (Talk | contribs)

Jump to: navigation, search

How to connect to a "normal" (not embedded) HSQL database?

  • Connect via JDBC
  • as driver class, use org.hsqldb.jdbcDriver
  • enter the URL to your HSQL database as described in the HSQLDB documentation, and append ;default_schema=true to the URL

How to migrate data between embedded and non-embedded HSQLDB?

 TODO

How to know the version of the embedded HSQLDB?

You can determine the version of the embedded HSQLDB engine with the following Basic macro [oobas] Option Explicit

Sub hsqlVersion

Dim databaseURLOrRegisteredName As String
databaseURLOrRegisteredName = "hsqldb"
 ' adjust this string to your needs. It needs to be the name of a registered database,
 ' or a complete URL
Dim databaseContext As Object
databaseContext = createUnoService( "com.sun.star.sdb.DatabaseContext" )
Dim databaseDocument As Object
databaseDocument = databaseContext.getByName( databaseURLOrRegisteredName )
Dim connection As Object
connection = databaseDocument.getConnection( "", "" )
MsgBox "product version: " & connection.getMetaData().getDatabaseProductVersion()
connection.close

End Sub Note that this will give you a version number such as "1.8.0", but not "1.8.0.1".

The minor version can be obtained by issueing a SQL statement in the query designer's "Direct SQL" mode:

 call "org.hsqldb.Library.getDatabaseFullProductVersion"()

will give you the full version. Drawbacks:

  • This is only available in 1.8.0.5 and later
  • in 1.8.0.5, it - wrongly - returns 1.8.0.4 :(
Personal tools