Re: [dba-dev] Changes to DB are not persistent
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
Re: [dba-dev] Changes to DB are not persistent
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
[dba-dev] Changes to DB are not persistent
Hello, I am new to this list, hello everybody! I already posted the following problem to d...@api.openoffice.org, but here it is probably more appropiate. Sorry! I've a problem with a Base-Application (Basic). See below for a codesample. 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? 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. Any ideas? Thanx a lot, Daniel REM * BASIC * Option Explicit REM Sub TestDB REM Inserts a new row into a database every time it is executed REM Requires a registered database called "test" with one column: "id" Sub TestDB Dim DBContext, DataSource, Connection As Object Dim Statement, ResultSet As Object Dim NrOfRows As Integer REM Establish database connection DBContext = createUnoService("com.sun.star.sdb.DatabaseContext") DataSource = DBContext.getByName("test") Connection = DataSource.GetConnection("","") REM Insert a new row into database Statement = Connection.createStatement() Statement.executeUpdate("INSERT INTO ""test"" (""id"") VALUES (NULL)") REM Count rows in database, to check if insertion did work ResultSet = Statement.executeQuery("SELECT COUNT(*) FROM ""test""") ResultSet.next NrOfRows = ResultSet.getInt(1) REM Show result MsgBox "Rows in database: " & NrOfRows REM The above code works, but changes to DB are not persistent. REM That means: after closing OOO the added rows are lost REM Flushing the DataSource helps, but ... (see mail) REM DataSource.flush() End Sub - To unsubscribe, e-mail: dev-unsubscr...@dba.openoffice.org For additional commands, e-mail: dev-h...@dba.openoffice.org