OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

odb files - extract and modify, zip - how does it work?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Thu Oct 04, 2007 2:17 am    Post subject: odb files - extract and modify, zip - how does it work? Reply with quote

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
View user's profile Send private message
acknak
Moderator
Moderator


Joined: 13 Aug 2004
Posts: 4295
Location: ~ 40°N,75°W

PostPosted: Thu Oct 04, 2007 7:33 am    Post subject: Reply with quote

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
View user's profile Send private message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Thu Oct 04, 2007 7:42 am    Post subject: Reply with quote

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
View user's profile Send private message
r4zoli
Super User
Super User


Joined: 17 May 2005
Posts: 570
Location: Budapest, Hungary

PostPosted: Thu Oct 04, 2007 9:43 am    Post subject: Reply with quote

http://digiassn.blogspot.com/2006/07/java-creating-jdbc-connection-to.html
Back to top
View user's profile Send private message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Fri Oct 05, 2007 2:53 am    Post subject: Reply with quote

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
View user's profile Send private message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Mon Oct 08, 2007 1:49 am    Post subject: Reply with quote

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
View user's profile Send private message
acknak
Moderator
Moderator


Joined: 13 Aug 2004
Posts: 4295
Location: ~ 40°N,75°W

PostPosted: Mon Oct 08, 2007 4:45 am    Post subject: Reply with quote

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
View user's profile Send private message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Mon Oct 08, 2007 6:38 am    Post subject: Reply with quote

ahhh... developers mailing list sounds like the place to go. Thanks.

andy
Back to top
View user's profile Send private message
andeeh
General User
General User


Joined: 03 Oct 2007
Posts: 6

PostPosted: Fri Oct 19, 2007 4:41 am    Post subject: Reply with quote

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
View user's profile Send private message
acknak
Moderator
Moderator


Joined: 13 Aug 2004
Posts: 4295
Location: ~ 40°N,75°W

PostPosted: Fri Oct 19, 2007 7:19 am    Post subject: Reply with quote

Cool. Thanks for the feedback.
Back to top
View user's profile Send private message
grahamweatherup
Newbie
Newbie


Joined: 29 Mar 2012
Posts: 1

PostPosted: Fri Apr 20, 2012 7:25 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group