Splitting an ODB File

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 14:23, 8 November 2010 (edit)
Amayze ( | contribs)

← Previous diff
Revision as of 14:30, 8 November 2010 (edit) (undo)
Amayze ( | contribs)

Next diff →
Line 1: Line 1:
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. 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 [http://www.oooforum.org oooForum], specifically this page [http://www.oooforum.org/forum/viewtopic.phtml?p=396523#396523].+This page is based on posting on the [http://www.oooforum.org oooForum], specifically this page [http://www.oooforum.org/forum/viewtopic.phtml?p=396523#396523 Base and HSQL together but not mixed? How to do it? - The Quick Fix].
Line 38: Line 38:
== Splitting you databse == == Splitting you databse ==
-This section is based on [http://www.oooforum.org/forum/viewtopic.phtml?p=386995#386995 this post] on the oooForum.+This section is based on [http://www.oooforum.org/forum/viewtopic.phtml?p=386995#386995 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.) 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.)
Line 115: Line 115:
Use the SQL Statement ALTER TABLE "TableName" ALTER COLUMN "TrueFalseField" SET DEFAULT FALSE (or TRUE as required) 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!

Revision as of 14:30, 8 November 2010

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 -> Preferences -> NeoOffice -> Java

Click on Class Path…

Click on 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).

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 select File->New->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 databse 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!

Personal tools