On Error Goto ErrorHandler 'Properties Dim properties(2) As New com.sun.star.beans.PropertyValue properties(0).Name = "user" properties(0).value = "UserName" properties(1).Name = "password" properties(1).value = "Pass" properties(2).name = "JavaDriverClass" properties(2).value = "org.postgresql.Driver" 'Driver manager Dim driverManager As Object driverManager = createUnoService("com.sun.star.sdbc.DriverManager") 'Connection Dim connection As Object connection = driverManager.getConnectionWithInfo("jdbc:postgresql://192.168.0.1:5432/database-name", properties()) 'Statement Dim statement As Object statement = connection.createStatement() 'Execute and number of update records Print statement.executeUpdate("DELETE FROM table1;") 'ResultSet Dim resultSet As Object resultSet = statement.executeQuery("SELECT * FROM table2;") While resultSet.Next Print resultSet.getString(1) Wend 'Close statement.close() connection.close() connection.dispose() Exit Sub 'Error handle ErrorHandler: If IsNull(statement) = false Then statement.close() End If If IsNull(connection) = false Then If connection.isClosed() = false Then connection.close() connection.dispose() End If End If If InStr(Error$, "org.postgresql.Driver") > 0 Then MsgBox("ツール→オプション→LibreOffice→詳細→クラスパスからPostgreSQLのJDBCドライバーを追加してください。", 64, "初期設定") Elseif Len(Error$) > 0 Then MsgBox(Error$, 16, "エラー") End If