Convert server database to embedded

Discuss the database features
Post Reply
User avatar
misitu
Posts: 104
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

Convert server database to embedded

Post by misitu »

Yes, I know this is backwards...

My aim (need) is to take a copy, like backup of script, database, properties, from the server instance and create from it an embedded instance. The reason is for offline work, trial data, demonstrations, and so on (every time I start the hsqldb service I'm in the habit of backing up afterwards in a variety of ways).

I've been looking at a number of different tweaks but so far I can't get the embedded version to start.

I'm looking at a scriptable solution using copy, 7zip, and so on.

Am quite stuck at the moment so any clues will be eagerly accepted.

AOO 4.1.6, Windows 11, HSQL 2.5.1 (upgrades paused for external causes)
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Convert server database to embedded

Post by Villeroy »

This is a backup script for Windows which safely backups the database without stopping the service. Adjust the absolute paths and names. Start it from the Windows task scheduler.

Code: Select all

REM Backup one database
SET DBN=MyDatabase
SET HOST=192.168.1.1
SET BDIR=E:\hsql\database\backups\
SET URL=jdbc:hsqldb:hsql://%HOST%/%DBN%,User=SA,Password=
SET JAR="E:\hsql\Drivers\hsqldb\lib\sqltool.jar"
SET CMD="BACKUP DATABASE TO '%BDIR%' BLOCKING AS FILES;"

E:
CD %BDIR%
DEL %DBN%.*
java.exe -jar %JAR% --sql %CMD%  --inlineRC url=%URL%
Inspecting the connection URL of an embedded HSQLDB, I get the following URL to be set.

Code: Select all

ThisComponent.DataSource.URL
which is "sdbc:embedded:hsqldb"

P.S.
AOO 4.1.6, Windows 11, HSQL 2.5.1 (upgrades paused for external causes)
You can not run embedded HSQL with version 2, unless you utilize https://prrvchr.github.io/jdbcDriverOOo/
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
misitu
Posts: 104
Joined: Mon Dec 16, 2013 5:34 am
Location: Trujillo - La Libertad - Perú

Re: Convert server database to embedded

Post by misitu »

Thanks!

Your suggestion in the main is what I already run.

I will attempt to explore further, it seemed to me that the zipped .odb of a server database when unzipped has some content radically different from that of an embedded. I've been looking for a tweak to map one to the other.



I am obliged for your swift response. Later, to confirm success or otherwise.
OpenOffice 4.1.1
HSQLDB 2.3.4
Windows 7 HP / Windows 10
OOBasic
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Convert server database to embedded

Post by Villeroy »

Create a new embedded HSQLDB.
Try running the CREATE statements of your script file. If this works, you get all the tables, relations and indices.
Copy the data.
Copy queries forms and reports.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply