Oracle SQL Developer 和 PostgreSQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7592519/
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
Oracle SQL Developer and PostgreSQL
提问by ramsvidor
I'm trying to connect to a PostgreSQL 9.1 database using Oracle SQL Developer 3.0.04, but I'm not having any success so far.
我正在尝试使用 Oracle SQL Developer 3.0.04 连接到 PostgreSQL 9.1 数据库,但到目前为止我没有任何成功。
First, if I add a third party driver on preferences, when adding a new connection there's no tab for PostgreSQL (it works fine for MySQL though). I'm using a JDBC4 version 9.1 driver, but I tried a JDBC3 of the same version and still get the same thing.
首先,如果我在首选项中添加第三方驱动程序,则在添加新连接时,没有用于 PostgreSQL 的选项卡(尽管它适用于 MySQL)。我使用的是 JDBC4 版本 9.1 驱动程序,但我尝试了相同版本的 JDBC3 并且仍然得到相同的结果。
Second, there's nothing like manual configuration tab when adding a new connection. The closest is the Advanced option on Oracle tab, where I can provide a custom URL, but it fails because complains about the selected Driver (of course).
其次,在添加新连接时,没有什么比手动配置选项卡更好的了。最接近的是 Oracle 选项卡上的 Advanced 选项,我可以在其中提供自定义 URL,但由于抱怨所选驱动程序(当然)而失败。
Finally, I got connected importing a connection from an XML file (contents below), but it displays only my schemas and doesn't show my tables inside them.
最后,我通过从 XML 文件(下面的内容)导入连接获得了连接,但它只显示了我的模式,并没有在其中显示我的表。
So, my question is: does Orable SQL Developer support PostgreSQL connections? Is there any other way to have my tables being displayed in the ObjectViewer?
所以,我的问题是:Orable SQL Developer 是否支持 PostgreSQL 连接?有没有其他方法可以让我的表格显示在 ObjectViewer 中?
<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
<Reference name="Lumea" className="oracle.jdeveloper.db.adapter.DatabaseProvider" credentialStoreKey="Lumea" xmlns="">
<Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
<RefAddresses>
<StringRefAddr addrType="user">
<Contents>lumea</Contents>
</StringRefAddr>
<StringRefAddr addrType="subtype">
<Contents>thirdParty</Contents>
</StringRefAddr>
<StringRefAddr addrType="customUrl">
<Contents>jdbc:postgresql://localhost:5432/versates</Contents>
</StringRefAddr>
<StringRefAddr addrType="SavePassword">
<Contents>true</Contents>
</StringRefAddr>
<StringRefAddr addrType="password">
<Contents>myencryptedpass</Contents>
</StringRefAddr>
<StringRefAddr addrType="driver">
<Contents>org.postgresql.Driver</Contents>
</StringRefAddr>
<StringRefAddr addrType="DeployPassword">
<Contents>true</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
</References>
回答by Ján Sáreník
Oracle SQL Developer 4.0.1.14 surely does support connections to PostgreSQL.
Oracle SQL Developer 4.0.1.14 确实支持连接到 PostgreSQL。
- download JDBC driver for Postgres (http://jdbc.postgresql.org/download.html)
- in SQL Developer go to
Tools → Preferences
,Database → Third Party JDBC Drivers
and add the jar file (see http://www.oracle.com/technetwork/products/migration/jdbc-migration-1923524.htmlfor step by step example) - now just make a new
Database Connection
and instead ofOracle
, selectPostgreSQL
tab
- 下载 Postgres 的 JDBC 驱动程序 ( http://jdbc.postgresql.org/download.html)
- 在 SQL Developer 中,转到
Tools → Preferences
,Database → Third Party JDBC Drivers
并添加 jar 文件(有关分步示例,请参见http://www.oracle.com/technetwork/products/migration/jdbc-migration-1923524.html) - 现在只需创建一个新的
Database Connection
,而不是Oracle
选择PostgreSQL
选项卡
Edit:
编辑:
If you have different user name and database name, one should specify in hostname: hostname/database?
(do not forget ?
) or hostname:port/database?
.
如果您有不同的用户名和数据库名,则应在主机名中指定:(hostname/database?
不要忘记?
)或hostname:port/database?
。
(thanks to @kinkajou and @Kloe2378231; more details on https://stackoverflow.com/a/28671213/565525).
(感谢@kinkajou 和@Kloe2378231;更多详情请见https://stackoverflow.com/a/28671213/565525)。
回答by John O
I've just downloaded SQL Developer 4.0 for OS X (10.9), it just got out of beta. I also downloaded the latest Postgres JDBC jar. On a lark I decided to install it (same method as other third party db drivers in SQL Dev), and it accepted it. Whenever I click "new connection", there is a tab now for Postgres... and clicking it shows a panel that asks for the database connection details.
我刚刚下载了适用于 OS X (10.9) 的 SQL Developer 4.0,它刚刚结束测试版。我还下载了最新的 Postgres JDBC jar。我决定安装它(与 SQL Dev 中的其他第三方数据库驱动程序相同的方法),并且它接受了它。每当我单击“新连接”时,现在都会有一个用于 Postgres 的选项卡...单击它会显示一个要求数据库连接详细信息的面板。
The answer to this question has changed, whether or not it is supported, it seems to work. There is a "choose database" button, that if clicked, gives you a dropdown list filled with available postgres databases. You create the connection, open it, and it lists the schemas in that database. Most postgres commands seem to work, though no psql commands (\list, etc).
这个问题的答案已经变了,不管是否支持,似乎都有效。有一个“选择数据库”按钮,如果单击该按钮,则会为您提供一个下拉列表,其中包含可用的 postgres 数据库。您创建连接,打开它,它会列出该数据库中的模式。大多数 postgres 命令似乎都可以工作,尽管没有 psql 命令(\list 等)。
Those who need a single tool to connect to multiple database engines can now use SQL Developer.
那些需要一个工具来连接多个数据库引擎的人现在可以使用 SQL Developer。
回答by francs
Oracle SQL Developer doesn't support connections to PostgreSQL. Use pgAdmin to connect to PostgreSQL instead, you can get it from the following URL http://www.pgadmin.org/download/windows.php
Oracle SQL Developer 不支持与 PostgreSQL 的连接。使用 pgAdmin 连接到 PostgreSQL,您可以从以下 URL http://www.pgadmin.org/download/windows.php获取它
回答by Panagiotis Piperopoulos
I managed to connect to postgres with SQL Developer. I downloaded postgres jdbc driver and saved it in a folder. I run SQL Developer -> Tools -> Preferences -> Search -> JDBC I defined postgres jdbc driver for the Database and Data Modeler (optional).
我设法使用 SQL Developer 连接到 postgres。我下载了 postgres jdbc 驱动程序并将其保存在一个文件夹中。我运行 SQL Developer -> Tools -> Preferences -> Search -> JDBC 我为数据库和数据建模器(可选)定义了 postgres jdbc 驱动程序。
This is the trick. When creating new connection define Hostname like localhost/crm? where crm is the database name. Test the connection, works fine.
这就是诀窍。创建新连接时定义主机名,如 localhost/crm?其中 crm 是数据库名称。测试连接,工作正常。
回答by GreenGiant
If there is no database with the same name as the username, then clicking "Choose Database" will fail with an error like "Status : Failure -FATAL: database "your_username" does not exist"
如果没有与用户名同名的数据库,则单击“选择数据库”将失败并显示类似“状态:失败 -FATAL:数据库“your_username”不存在”的错误
To work around this, put 5432/database_name?
in the Portfield, where 5432
is the port of your Postgres instance and database_name
is the name of at an existing database that your_username
has access to. Then click "Choose Database" again and it should work. Now you can choose the database you want and remove the extra /database_name?
from the Port field.
要解决此问题,请5432/database_name?
输入Port字段,其中5432
是 Postgres 实例的端口,database_name
是可your_username
访问的现有数据库的名称。然后再次单击“选择数据库”,它应该可以工作。现在您可以选择所需的数据库并/database_name?
从端口字段中删除额外的数据库。
回答by substars
I got the list of databases to populate by putting my username in the Username field (no password) and clicking "Choose Database". Doesn't work with a blank Username field, I can only connect to my user database that way.
通过将我的用户名放入用户名字段(无密码)并单击“选择数据库”,我获得了要填充的数据库列表。不适用于空白的用户名字段,我只能以这种方式连接到我的用户数据库。
(This was with SQL Developer 4.0.0.13, Postgres.app 9.3.0.0, and postgresql-9.3-1100.jdbc41.jar, FWIW.)
(这是 SQL Developer 4.0.0.13、Postgres.app 9.3.0.0 和 postgresql-9.3-1100.jdbc41.jar,FWIW。)
回答by James McPherson
I think this question needs an updated answer, because both PostgreSQL and SQLDeveloper have been updated several times since it was originally asked.
我认为这个问题需要一个更新的答案,因为 PostgreSQL 和 SQLDeveloper 自从最初被问到以来已经更新了几次。
I've got a PostgreSQL instance running in Azure, with SSLMODE=Require. While I've been using DBeaverCE to access that instance and generate an ER Diagram, I've gotten really familiar with SQLDeveloper, which is now at v19.4.
我有一个在 Azure 中运行的 PostgreSQL 实例,SSLMODE=Require。虽然我一直在使用 DBeaverCE 访问该实例并生成 ER 图表,但我已经非常熟悉 SQLDeveloper,它现在是 v19.4。
The instructions about downloading the latest PostgreSQL JDBC driver and where to place it are correct. What haschanged, though, is where to configure your DB access.
有关下载最新 PostgreSQL JDBC 驱动程序及其放置位置的说明是正确的。什么已经改变了,虽然是在哪里配置数据库的访问。
You'll find a file $HOME/.sqldeveloper/system19.4.0.354.1759/o.jdeveloper.db.connection.19.3.0.354.1759/connections.json
:
你会找到一个文件$HOME/.sqldeveloper/system19.4.0.354.1759/o.jdeveloper.db.connection.19.3.0.354.1759/connections.json
:
{
"connections": [
{
"name": "connection-name-goes-here",
"type": "jdbc",
"info": {
"customUrl": "jdbc:postgresql://your-postgresql-host:5432/DBNAME?sslmode=require",
"hostname": "your-postgresql-host",
"driver": "org.postgresql.Driver",
"subtype": "SDPostgreSQL",
"port": "5432",
"SavePassword": "false",
"RaptorConnectionType": "SDPostgreSQL",
"user": "your_admin_user",
"sslmode": "require"
}
}
]
}
You can use this connection with both Data Modeller and the admin functionality of SQLDeveloper. Specifying all the port, dbname and sslmode in the customUrl are required because SQLDeveloper isn't including the sslmode in what it sends via JDBC, so you have to construct it by hand.
您可以将此连接与 Data Modeller 和 SQLDeveloper 的管理功能一起使用。在 customUrl 中指定所有端口、dbname 和 sslmode 是必需的,因为 SQLDeveloper 没有在它通过 JDBC 发送的内容中包含 sslmode,因此您必须手动构建它。
回答by DONG
Except that it will not work if your user name and database name are differents. It sounds like an SQLDeveloper bug and i can't find any workaroud
除非您的用户名和数据库名不同,否则它将不起作用。这听起来像是一个 SQLDeveloper 错误,我找不到任何解决方法
Maybe there are some bugs in Oracle SQL Developer when it connect to the postgresql.However I connect postgresql with navicat successfully.(My postgresql username and database name are different
Oracle SQL Developer 连接 postgresql 时可能存在一些错误。但是我成功连接了 postgresql 和 navicat。(我的 postgresql 用户名和数据库名称不同