Xalos – utilidades de conexion a PostgreSQL
ahora ando full exportando desde jasper, la idea es hacer un plugin que permita hacerlo de forma transparente, lidiando con java y C y los xml forms veo que la unica forma viable de hacer cosas en LibreOffice es mediante su star basic script.
a continuacion lo que desarrolle y encontre con respecto a conectarme a PostgreSQL
Dim sURL as String
Public SQLKeywords as String
Dim InfoProperties(6) as New com.sun.star.beans.PropertyValue
Public oConnection as Object
Function Connect() as Boolean
if isnull (oConnection) then
Dim driverManager As Object
driverManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
'Fill the Info-Array of the DataSource with extra Values
sURL = "jdbc:postgresql://" & dbserver & ":" & dbport & "/" & dbname
InfoProperties(0).Name = "AutoIncrementCreation"
InfoProperties(0).Value = ""
InfoProperties(1).Name = "AutoRetrievingStatement"
InfoProperties(1).Value = ""
InfoProperties(2).Name = "EnableSQL92Check"
InfoProperties(2).Value = False
InfoProperties(3).Name = "IsAutoRetrievingEnabled"
InfoProperties(3).Value = False
InfoProperties(4).Name = "JavaDriverClass"
InfoProperties(4).Value = "org.postgresql.Driver"
InfoProperties(5).Name = "user"
InfoProperties(5).Value = dbuser
InfoProperties(6).Name = "password"
InfoProperties(6).Value = dbpwd
oConnection = driverManager.getConnectionWithInfo( sURL, InfoProperties() )
SQLKeywords = oConnection.getMetaData().getSQLKeywords()
else
rem oConnection.dispose
End if
Connect = true
End Function
Function getDBValueString (oSql as String) as String
Dim oRowSet as Object
Dim qcount
Connect()
oRowSet = createUnoService("com.sun.star.sdb.RowSet")
oRowSet.activeConnection = oConnection
oRowSet.Command = oSql
oRowSet.execute
qcount = oRowSet.getPropertyValue("RowCount")
if oRowSet.next() then
getDBValueString = oRowSet.getString(1)
else
getDBValueString = ""
end if
oRowSet.close
End Function