Re: [dba-dev] Changes to DB are not persistent

2010-12-22 Thread listsandstuff
Hello Frank,

Frank Schönheit schrieb:

 That's a good hint. I experimented with Connection.close(), but it 
 didn't solve the problem.
 
 Hmm, I would have expected this to implicitly flush the changes.

You're perfectly right. I just re-checked the code and I must have been
making some mistake earlier this day. A single Connection.Close()
flushes the changes and removes the lock.

 But freeing the DataSource with DataSource.Dispose() seems to work.
 
 Not a good idea, see below.

That's true as well. DataSource.Dispose() doesn't seem to do any harm
when I test the code with an old OOO 2.4 (as I did earlier) but crashes
OOO 3.2.1 reproduceably.

I'll review my code after Christmas and watch for the windows-problem,
but I suspect some mistake with un-closed connections resulting in
problems with locking (like a lock is held by an unclosed connection
...). Definitely my mistake and not an OOO-issue.

Thank You very much for Your profound explanation. I'm rather new to
OOO-coding, so your help is very welcome

Bye,
Daniel.


-
To unsubscribe, e-mail: dev-unsubscr...@dba.openoffice.org
For additional commands, e-mail: dev-h...@dba.openoffice.org



Re: [dba-dev] Changes to DB are not persistent

2010-12-21 Thread Frank Schönheit
Hi Daniel,

 The code is adding a row to a database (Base-Document with embedded
 HSQL-DB) every time it gets called. However the changes are lost after
 closing OOO. To make them permanent it's necessary to flush() the
 DataSource.
 
 First question: This is not exspected bahaviour, is it? Changes should
 be persistently saved without calling flush(), or am I wrong?

Well ... the problem with the ZIP-file approach of ODBs is that it is
impossible to immediately write all changes you did to the file.
(Anybody wishing to start a discussion how this violates fundamental
database principles ... please direct your concerns to the ODF faction.
I'd be grateful for any assistance in explaining why ZIP as a database
backend is a joke, at best.) That's basically a question of performance.

So, some kind of flushing is necessary. This is inconvenient, but in the
above sense, expected behavior.

However, note that your macro contains a resource leak, in that it
retrieves a connection, which it does not dispose afterwards - at the
very end of the Sub, you should have a
  Connection.close()
This should free the resources associated with the connection, and at
the same time flush its changes.

 But the trouble gets worse... The flush() - workaround works fine on
 Linux (Using OOO 3.2.1 and 2.4 on Debian), but it crashes OOO 3.2.1 on
 Windows (XP) ungracefully.

If you can create a small self-contained .odb (including the macro)
showing this, please submit an issue at
http://www.openoffice.org/issues/enter_bug.cgi?component=Database%20access.
Feel free to assign it to me (fs).

Ciao
Frank

-- 
ORACLE
Frank Schönheit | Software Engineer | frank.schoenh...@oracle.com
Oracle Office Productivity: http://www.oracle.com/office

-
To unsubscribe, e-mail: dev-unsubscr...@dba.openoffice.org
For additional commands, e-mail: dev-h...@dba.openoffice.org



Re: [dba-dev] Changes to DB are not persistent

2010-12-21 Thread Alex Thurgood
Hi Daniel,

How about using commit() or setting up the connection instance as autoCommit ?


http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/XConnection.html#commit

http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/XConnection.html#setAutoCommit

Alex

-
To unsubscribe, e-mail: dev-unsubscr...@dba.openoffice.org
For additional commands, e-mail: dev-h...@dba.openoffice.org