database - 在 LibreOffice 中,如何仅使用 Basic 连接到 Oracle 数据库
问题描述
我正在尝试将 Oracle 数据导入我的 OfficeBase 数据库 (FireBird)。我的目标是打开一条直接连接到 oracle 的记录,如下所示:
- 使用正确的连接字符串连接到 oracle 数据库
- 使用适当的 SQL 获取数据
- 使用循环遍历记录
谢谢大家的帮助。
解决方案
我想我找到了答案:
Sub Main
Dim oParms() As New com.sun.star.beans.PropertyValue
sUser$ = "uid"
sPass$ = "pwd"
sURL$ = "jdbc:postgresql://localhost:5432/postgres"
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
AppendProperty(oParms(), "user", sUser)
AppendProperty(oParms(), "password", sPass)
AppendProperty(oParms(), "JavaDriverClass", "org.postgresql.Driver")
oCon = oManager.getConnectionWithInfo(sURL, oParms())
oStatement = oCon.CreateStatement()
sSQL = "select * from table order by id desc"
oResult = oStatement.executeQuery(sSQL)
Do While oResult.next()
s = oResult.getString(3)
print s
Loop
oCon.close()
End Sub
Sub AppendProperty(oProperties(), sName As String, ByVal oValue)
AppendToArray(oProperties(), CreateProperty(sName, oValue))
End Sub
Sub AppendToArray(oData(), ByVal x)
Dim iUB As Integer 'The upper bound of the array.
Dim iLB As Integer 'The lower bound of the array.
iUB = UBound(oData()) + 1
iLB = LBound(oData())
ReDim Preserve oData(iLB To iUB)
oData(iUB) = x
End Sub
Function CreateProperty(sName$, oValue) As com.sun.star.beans.PropertyValue
Dim oProperty As New com.sun.star.beans.PropertyValue
oProperty.Name = sName
oProperty.Value = oValue
CreateProperty() = oProperty
End Function
推荐阅读
- python - 如何使用 pywin32 在 Python 中获取特定应用程序窗口的句柄?
- asp.net - 如何在 ASP.NET 身份框架中从用户中删除所有角色
- javascript - Rxjs v6.x 上的类型“事件”.ts(2339) 上不存在属性“clientX”
- angular - 为什么在 empForm.reset(); 之后 标记为无效错误的必填字段?
- node.js - Asnyc Express Midleware 工作的原因是什么?
- visual-studio-code - 在 Visual Studio Code 的 preLaunchTask 中使用 launch.json 中的“输入”选择
- javascript - 如何在 JavaScript 中删除类对象的引用?
- python - 如何根据 Pandas Dataframe 中的列值为绘图上的特定数据点着色
- python - Plotly:如何根据列值设置标记大小?
- visual-studio-code - 如何在鼠标悬停弹出窗口中的文档上方显示错误/警告?