使用 SDBC 从 libreoffice base 连接到 PostgreSQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16356011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Connect to PostgreSQL from libreoffice base with SDBC
提问by Pierre
I'm trying to open a connection to a PostgreSQL database from LibreOffice with SDBC. After installing the "postrgre-sdbc-0.7.6" plugin, the "postgresql" datasource appears. The system asks for the datasource URL where I enter my IP
我正在尝试使用 SDBC 从 LibreOffice 打开到 PostgreSQL 数据库的连接。安装“postrgre-sdbc-0.7.6”插件后,会出现“postgresql”数据源。系统要求我输入 IP 的数据源 URL
192.168.0.12
then my user name, ticks the "Password required" box, and after entering my password the "Test connection" button gives me the following error message.
然后是我的用户名,勾选“需要密码”框,输入密码后,“测试连接”按钮显示以下错误消息。
A driver is not registered for the URL sdbc:postresql:192.168.0.12
I tried adding the port to the URL (192.168.0.12:5432), same error. As suggested I also rebooted both base and the computer, no luck either.
我尝试将端口添加到 URL (192.168.0.12:5432),同样的错误。正如建议的那样,我还重新启动了基座和计算机,但也不走运。
I know the server is running correctly as I access it no problem from pgAdminIII with these parameters.
我知道服务器运行正常,因为我使用这些参数从 pgAdminIII 访问它没有问题。
As suggested by Richard, I also tried
按照理查德的建议,我也尝试过
host=192.168.0.12 port=5432 dbname=dataerp connect_timeout=10
host=192.168.0.12 port=5432 dbname=dataerp
host=192.168.0.12 dbname=dataerp
dbname=dataerp host=192.168.0.12
also
还
//192.168.0.12/dataerp
//192.168.0.12:5432/dataerp
192.168.0.12:5432:dataerp
192.168.0.12:5432:dataerp:myusername:mypassword
192.168.0.12:5432=dataerp
Nothing works, I still get the same error message Any help welcome!
没有任何效果,我仍然收到相同的错误消息,欢迎任何帮助!
After investigations, I had installed the postgresql ODBC driver doing
经过调查,我已经安装了postgresql ODBC驱动程序
sudo apt-get install odbc-postgresql
While what was needed was:
虽然需要的是:
sudo apt-get install libreoffice-sdbc-postgresql
The correct connection syntax was
正确的连接语法是
host=192.168.0.12 port=5432 dbname=dataerp
Do not forget to reboot after this or it won't work! This tip was found here
之后不要忘记重新启动,否则它将无法工作!这个提示是在这里找到的
回答by Richard Huxton
You don't want a raw IP address, you want a libpq connection string.
您不需要原始 IP 地址,而是需要 libpq 连接字符串。
A quick google for "sdbc postgresql url" would give you the sdbc driver pagewhich gives an example, and a link to the PostgreSQL docs.
快速搜索“sdbc postgresql url”将为您提供sdbc 驱动程序页面,其中提供了一个示例,以及一个到PostgreSQL 文档的链接。
In short you want a string something like
简而言之,你想要一个类似的字符串
dbname=mydatabase host=192.168.0.12 or postgresql://localhost:5432/mydatabase
There are other options for port etc too - see the docs above in the "Connection Strings" section.
还有其他端口等选项 - 请参阅上面“连接字符串”部分中的文档。
回答by Abdur Rahmaan
The best way is to download jdbc jar file postgresql and do the following, Add the JAR file containing the PostGreSQL driver to OOo's CLASSPATH. This is what I do to add new JDBC drivers to OOo's CLASSPATH: In OOo call "Tools" > "Options" > "OpenOffice.org" > "Java" > press "Class Path..." > press "Add Archive..." > locate and select the archive. Now go for the new db connection by selecting jdbc. thats all
最好的方法是下载 jdbc jar 文件 postgresql 并执行以下操作,将包含 PostGreSQL 驱动程序的 JAR 文件添加到 OOo 的 CLASSPATH。这是我将新的 JDBC 驱动程序添加到 OOo 的 CLASSPATH 所做的工作:在 OOo 中调用“工具”>“选项”>“OpenOffice.org”>“Java”> 按“类路径...”> 按“添加存档.. ." > 找到并选择存档。现在通过选择 jdbc 去建立新的数据库连接。就这样