Difference between revisions of "HSQLDB:Tips and Tricks"
From Apache OpenOffice Wiki
m (HSQLDB: Tips and Tricks moved to HSQLDB:Tips and Tricks) |
|||
| Line 6: | Line 6: | ||
= How to know the version of the embedded HSQLDB? = | = How to know the version of the embedded HSQLDB? = | ||
| − | + | You can determine the version of the embedded HSQLDB engine with the following Basic macro | |
| + | <code>[basic] | ||
| + | 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 | ||
| + | </code> | ||
| + | Note that this will give you a version number such as "1.8.0", but ''not'' "1.8.0.1". To my best knowledge, this last digit in the HSQLDB version cannot be obtained by any means at runtime. | ||
Revision as of 14:07, 16 November 2005
How to connect to a "normal" (not embedded) HSQL database?
TODO
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
[basic]
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". To my best knowledge, this last digit in the HSQLDB version cannot be obtained by any means at runtime.