Apache OpenOffice (AOO) Bugzilla – Issue 117279
doImport function cause OpenOffice to crash
Last modified: 2023-07-28 18:05:57 UTC
Using OpenOffice to connect to Postgresql Database with PostgreSQL SDBC driver. Calc document have written macro which connect to Postgres, and throw data into spreadsheet. Step by step inspection of macro showed that OpenOffice crash on line: "oSheet.getcellbyposition(0,3+j).doImport(vAttrib)" Suspected that the problem is caused by Java version, but it happened on all Javas I have tested: - Sun Microsystems 1.6.0_13 - Sun Microsystems 1.6.0_20 with acceasability support - Sun Microsystems 1.6.0_24 - Free Software Foundation 1.5.0 The best results were with - Sun Microsystems 1.6.0_20 with acceasability support. For the moment before the OpenOffice crashed I could see that doImport pasted data into spreadsheet. OpenOffice don't throw anything on the console, which could help to backtrace. The doImport function is very useful one, and I guess that many users are using (or will be) using it. Below the code which cause crash. sub hall_insert Dim DatabaseContext As Object Dim DataSource As Object Dim Connection As Object Dim InteractionHandler as Object Dim Statement As Object Dim ResultSet As Object Dim oSheet as Object sTemp$ = "Temperatura, K" baza="baza_mocvd" oSheet=thiscomponent.sheets.getbyName("Hall") oCellRange = oSheet.getCellRangeByName("A5:I50") oCellRange.clearContents(com.sun.star.sheet.CellFlags.VALUE) oCellRange.clearContents(com.sun.star.sheet.CellFlags.STRING) 'oCellRange.clearContents(com.sun.star.sheet.CellFlags.FORMULA) DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext") DataSource = DatabaseContext.getByName(baza) If Not DataSource.IsPasswordRequired Then Connection = DataSource.GetConnection("","") Else InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler") Connection = DataSource.ConnectWithCompletion(InteractionHandler) End If If oSheet.getCellByPosition(1,0).getString() = "" then oSheet.getCellByPosition(1,0).setValue(0) process_list = oSheet.getCellByPosition(1,0).getString() Statement = Connection.createStatement() ResultSet = Statement.executeQuery("SELECT hall_id,process_id, temperature FROM erp.hall where process_id in(" +process_list+ ") order by temperature DESC, process_id DESC,thickness ASC" ) If Not IsNull(ResultSet) Then ResultSet.last 'Move to the LAST record, to determine the Record Count j = ResultSet.Row 'Added a variable with the number of records returned ResultSet.beforeFirst() While ResultSet.next hall_id=ResultSet.getString(1) process_id=ResultSet.getString(2) temperature=ResultSet.getString(3) sSQL= "SELECT process_id,temperature, depth, rsq, uh, ns/thickness*10000 AS ""nh, cm-3"", thickness, remarks, surveyor FROM erp.hall AS h WHERE process_id=" + process_id + "AND temperature="+temperature ' I am using MakeProperty function written by DannyB, available in thousand references over this site, mean and clean. ;) vAttrib=Array(MakePropertyValue("DatabaseName", baza), MakePropertyValue( "SourceType", "SQL" ), MakePropertyValue( "SourceObject", sSQL)) 'Now the import, quick and nice. ;) oSheet.getcellbyposition(0,3+j).doImport(vAttrib) j=j-1 Wend End If ResultSet.dispose() Connection.close() end sub 'by DannyB Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function
getting rid of value "enhancement" for field "severity". For enhancement the field "issue type" shall be used.
(In reply to h0l0fernes from comment #0) > Using OpenOffice to connect to Postgresql Database with PostgreSQL SDBC > driver. What you called SDBC? Base has not this native driver in 3.x. Did you means JDBC or ODBC? >Suspected that the problem is caused by Java version All these versions are obsolete now Try to test with recent AOO build in 4.x and Adoptium JRE. Please report back if still occurs.