| View previous topic :: View next topic |
| Author |
Message |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Thu Oct 04, 2007 2:17 am Post subject: odb files - extract and modify, zip - how does it work? |
|
|
Hi,
I'm wondering what the mechanism is that allows Base to open and read the HSQL files contained in the odb zip? Specifically, does Base extract the zip to a temporary location and THEN read using hsql? or what is happening here?
I'm writing some java code to extract the contents of the odb file and then read them directly with a standalone app. To use an UNO instance and java apis is not really what I want to do. Is there is a simple standalone jar file that can manipulate (eg extract and manage the manifest) odb files directly?
Finally, I noticed that the lock file (xxxxxx.lck) is placed next to the odb file when Base opens it. A glance at this .lck file and it seems to be the hsql lock file - as if the hsql engine is reading the zip file directly. What is going on here?
Sorry if this has been covered before. I can't find this information anywhere. Right now im writing some routines to extract and read the hsql and then zip it all up again when the db connection is closed... I might be re-inventing the wheel though!
andeeh |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Thu Oct 04, 2007 7:33 am Post subject: |
|
|
| You should probably specify what OS you're working with--OOo may handle this differently on different systems. Probably not, but maybe. |
|
| Back to top |
|
 |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Thu Oct 04, 2007 7:42 am Post subject: |
|
|
| It's on Windows XP right now. I expect that the differences are minor as the file format is universal zip based and HSQL is a pure java DB. |
|
| Back to top |
|
 |
r4zoli Super User

Joined: 17 May 2005 Posts: 570 Location: Budapest, Hungary
|
|
| Back to top |
|
 |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Fri Oct 05, 2007 2:53 am Post subject: |
|
|
| thanks, yes I've seen that snippet but it doesn't explain how openoffice appears to be piping the data from the zip directly to the hsql engine. If open office is extracting the zip, where is the cache of the extracted data and why is the hsql lock file in the same place as the odb file? |
|
| Back to top |
|
 |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Mon Oct 08, 2007 1:49 am Post subject: |
|
|
Another interesting question: is the HSQL connection shut down before the odb file is saved?
If I have an odb database and change some data then I don't need to explicitly save it using the save button. However, if I add a new form to the same database I have to explicitly save this or my changes will be lost.
I expect that database changes are only committed when the file is closed and only then are the hsql files "properties, backup, script, log, data" zipped into the odb file.
A description of this process would be very helpful I think. It would be great to have a java api to read and write to an odb. |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Mon Oct 08, 2007 4:45 am Post subject: |
|
|
Don't forget: you have the "ultimate documentation": the source code. It can be a challenge to wade through it, but using the indexed, searchable, hyperlinked source available from go-ooo.org, it's pretty straightforward to find the right piece of code.
Then, if you have specific questions about he code, try asking on one of the development mailing lists. I've found that the developers are very helpful. |
|
| Back to top |
|
 |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Mon Oct 08, 2007 6:38 am Post subject: |
|
|
ahhh... developers mailing list sounds like the place to go. Thanks.
andy |
|
| Back to top |
|
 |
andeeh General User

Joined: 03 Oct 2007 Posts: 6
|
Posted: Fri Oct 19, 2007 4:41 am Post subject: |
|
|
I got a reply in the mailing lists and I've written a little code to do basic new/open/save/save as/close operations. Some of it is a hack, especially the generation of manifests and content.xml. It seems to work fine though.
Anyone can PM me if they want a zip of code.
FYI Below is the reply I got from Frank Schönheit over on the developer mailing lists.
cheers,
Andy
*****
| Quote: | Conceptually, we unzip the files from the .odb (they're all located in
the "database" sub folder of the zip), and let HSQLDB work on those
external copies, as if they were a normal file-based database. From time
to time (too often to be really unobtrusive, but too seldom to really
guarantee your data is there even if you pull the plug just after you
entered it), the copies are synced back to the .odb.
This is probably also the way you should be going.
(Note that technically, it's not exactly like this. Instead, we use a
feature of HSQL to use some kind of virtualized file access, and
re-route all its file access operations to our .odb-external copies of
the files in the "database" sub folder.) |
|
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Fri Oct 19, 2007 7:19 am Post subject: |
|
|
| Cool. Thanks for the feedback. |
|
| Back to top |
|
 |
grahamweatherup Newbie

Joined: 29 Mar 2012 Posts: 1
|
Posted: Fri Apr 20, 2012 7:25 am Post subject: |
|
|
| I would be interested in using the code talked about here in our software project PAMGUARD which we release under GNU. I have PMd Andy but wondered if anyone else had his code and knew how he allowed it to be used? |
|
| Back to top |
|
 |
|