|
Splitting an ODB File
From NeoWiki
By default NeoOffice uses the embedded HSQL 1.8 database engine when creating a odb file. This is fine for quick development, but it can cause problems data loss problems if NeoOffice crashes and it makes it hard to deploy updated forms and reports to the user if you are developing a database for someone else. By splitting the database from the odb file the HSQL databse engine runs as a separate process and is unaffected inthe event of a NeoOffice crash.
This page is based on posting on the oooForum, specifically this page Base and HSQL together but not mixed? How to do it? - The Quick Fix.
Contents |
Setting up NeoOffice
- Start NeoOffice
- Select NeoOffice then Preferences
- In the Preferences window select NeoOffice then Java
- Click on the button Class Path…
- Click on the button Add Archive…
- Type Shift-Cmd-G
- Enter the path /Applications/NeoOffice.app/Contents/basis-link/program/classes/ and click Go(N.B. you can type the first few letter of each folder name and press TAB to speed things up).
- Click the button Go
- Select the file hsqldb.jar and click and click Open.
- Click OK to get rid of all the dialogue boxes and restart NeoOffice.
Testing it works
Download the file mydb.odb
Create a folder in your Users folder called public/databases/mydb/
Copy the mydb.odb file into this folder.
Open the mydb.odb file
It is an empty database. Add some tables to it. You should see several new files appear in the mydb folder that the mydb.odb file is in.
Splitting you databse
This section is based on Printing Multiple Values in One Field - Migrating an existing database from the all-inclusive database file (.odb) to a robust multi-mode database: on the oooForum.
Make a copy of your odb file (from now on we will call the database <dbname> so the odb file is called <dbname>.odb, so if your database is called fred.db then all occurences of <dbname> should be replaced with fred.)
Drag the copy of the database to the folder /Users/public/databases/<dbname>
Make sure it is called <dbname>.odb
Make another copy of this file and change the extension to .zip
Extract the files (using BOM Archive Helper or Stuffit Expander). There should now be a folder call <dbname> or <dbname> Folder
Double click this folder and then on the folder database
Rename the files in this folder by pre-pending the name of your database and a period. ie backup becomes <dbname>.backup, data <dbname>.data, etc.
Copy these renamed files back down the folder hierarchy to the <dbname> folder with the .odb file in it.
Rename the .odb file old<dbname>.odb
In NeoOffice from the File select New then Database
Select Connect to an Existing Database and select JDBC. Click Next
In the Data Source URL box enter: hsqldb:file:/users/public/databases/<dbname>/<dbname>;default_schema=true;shutdown=true;hsqldb.default_table_type=cached;get_column_name=false
In the JDBC driver class box enter: org.hsqldb.jdbcDriver (NB there must not be a space at the end of this string)
Click Next
Enter SA as the Username
Click Next
Select to register the database and open it for editing.
Save the file as <dbname>.odb in the /users/public/databases/<dbname> folder
You should now have a database with no Queries, Form or Reports. However all of your tables should be visible.
Copying across Queries, Forms and Reports
Open both old<dbname>.odb and <dbname>.odb
Drag each of the Queries, Forms and Reports from old<dbname>.odb to the corresponding section of <dbname>.odb
You will need to re-enter the name of all of the Queries. Make sure you don't make any typos!
Copying across Macros
With old<dbname>.odb open select Tools->Macros-> Organise Macros->NeoOffice Basic
Select one of your Macro Modules and click Edit.
Save each module using the Save BASIC button.
With <dbname>.odb open select Tools->Macros-> Organise Macros->NeoOffice Basic
Create a new Module in <dbname>
Load in the macros you saved above using the Insert BASIC Source button.
Save each module with the same name as it had before.
Tidying up
The databse is now split in to separate databse and odb files and should work ok. I have however had a few problems with Autonumber fields and checkboxes
Autonumber Fields: These seem to forget the next index, resulting in duplicate entries and failure to insert records due to duplicate Primary key fields.
Select Tools->SQL…
Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "PrimaryKeyField" RESTART WITH xxx where xxx is the next unused value in the table.
Checkboxes: These seem to default to NULL which can cause problems
Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "TrueFalseField" SET DEFAULT FALSE (or TRUE as required)
Conclusion
Everything should now work as before, but should NeoOffice crash it is much less likely that you will loose data. Also if you are developing a database for a client you can duplicate the above setup on their machine and yours. As you develop new versions of the Forms, Queries and Reports you can simply send then an updated odb file to copy over the old one. Their data will be unaffected. Obviously if you make changes to the tables you will have to visit the client or give them a list of steps or SQL commands to enter, but for the purposes of this guide I'll assume you know what you are doing if you are doing that!