简体   繁体   English

Oracle SQL 开发者和 PostgreSQL

[英]Oracle SQL Developer and PostgreSQL

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).首先,如果我在首选项中添加第三方驱动程序,则在添加新连接时,没有 PostgreSQL 的选项卡(尽管它适用于 MySQL)。 I'm using a JDBC4 version 9.1 driver, but I tried a JDBC3 of the same version and still get the same thing.我正在使用 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 选项卡上的高级选项,我可以在其中提供自定义 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?所以,我的问题是:Orable SQL Developer 是否支持 PostgreSQL 连接? Is there any other way to have my tables being displayed in the ObjectViewer?有没有其他方法可以让我的表格显示在 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>

Oracle SQL Developer 4.0.1.14 surely does support connections to PostgreSQL. Oracle SQL Developer 4.0.1.14 确实支持连接到 PostgreSQL。

Edit :编辑

If you have different user name and database name, one should specify in hostname: hostname/database?如果您有不同的用户名和数据库名,则应在主机hostname/database?指定: hostname/database? (do not forget ? ) or hostname:port/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 )。

I've just downloaded SQL Developer 4.0 for OS X (10.9), it just got out of beta.我刚刚下载了适用于 OS X (10.9) 的 SQL Developer 4.0,它刚刚结束测试版。 I also downloaded the latest Postgres JDBC jar .我还下载了最新的 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.我决定安装它(与 SQL Dev 中的其他第三方数据库驱动程序相同的方法),并且它接受了它。 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.每当我单击“新连接”时,现在都会有一个用于 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.有一个“选择数据库”按钮,如果单击该按钮,则会为您提供一个下拉列表,其中包含可用的 postgres 数据库。 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 命令似乎都可以工作,尽管没有 psql 命令(\\list 等)。

Those who need a single tool to connect to multiple database engines can now use SQL Developer.那些需要一个工具来连接多个数据库引擎的人现在可以使用 SQL Developer。

Oracle SQL Developer doesn't support connections to PostgreSQL. Oracle SQL Developer 不支持与 PostgreSQL 的连接。 Use pgAdmin to connect to PostgreSQL instead, you can get it from the following URL http://www.pgadmin.org/download/windows.php使用 pgAdmin 连接到 PostgreSQL,您可以从以下 URL http://www.pgadmin.org/download/windows.php获取它

I managed to connect to postgres with SQL Developer.我设法使用 SQL Developer 连接到 postgres。 I downloaded postgres jdbc driver and saved it in a folder.我下载了 postgres jdbc 驱动程序并将其保存在一个文件夹中。 I run SQL Developer -> Tools -> Preferences -> Search -> JDBC I defined postgres jdbc driver for the Database and Data Modeler (optional).我运行 SQL Developer -> 工具 -> 首选项 -> 搜索 -> JDBC 我为数据库和数据建模器定义了 postgres jdbc 驱动程序(可选)。

This is the trick.这就是诀窍。 When creating new connection define Hostname like localhost/crm?创建新连接时定义主机名,如 localhost/crm? where crm is the database name.其中 crm 是数据库名称。 Test the connection, works fine.测试连接,工作正常。

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.我有一个在 Azure 中运行的 PostgreSQL 实例,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.虽然我一直在使用 DBeaverCE 访问该实例并生成 ER 图表,但我已经非常熟悉 SQLDeveloper,它现在是 v19.4。

The instructions about downloading the latest PostgreSQL JDBC driver and where to place it are correct.有关下载最新 PostgreSQL JDBC 驱动程序及其放置位置的说明是正确的。 What has changed, though, is where to configure your DB access.发生什么变化,不过,在这里指定您的数据库访问。

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.您可以将此连接与 Data Modeller 和 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.在 customUrl 中指定所有端口、dbname 和 sslmode 是必需的,因为 SQLDeveloper 没有在它通过 JDBC 发送的内容中包含 sslmode,因此您必须手动构建它。

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。)

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?要解决此问题,请将5432/database_name? in the Port field, 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.Port字段中,其中5432是 Postgres 实例的端口, database_nameyour_username可以访问的现有数据库的名称。 Then click "Choose Database" again and it should work.然后再次单击“选择数据库”,它应该可以工作。 Now you can choose the database you want and remove the extra /database_name?现在您可以选择您想要的数据库并删除额外的/database_name? from the Port field.从端口字段。

Oracle SQL Developer 2020-02 support PostgreSQL, but it is just the basics by adding postgreSQL driver under jdbc dir and configure by adding as a 3rd party driver. Oracle SQL Developer 2020-02 支持 PostgreSQL,但这只是基础,通过在 jdbc 目录下添加 postgreSQL 驱动程序并通过添加为 3rd 方驱动程序进行配置。

The supported functionality:支持的功能:

  • multiple databases which can be selected at connection definition可以在连接定义中选择的多个数据库
  • CRUD operations like query tables CRUD 操作,如查询表
  • scheme operations计划操作
  • basic modelling support: show tables without pk, fk, connections基本建模支持:显示没有 pk、fk、连接的表

Not supported functionalities:不支持的功能:

  • no table or field completion没有表格或字段完成
  • no indexes are shown in a tab标签中没有显示索引
  • no constraints are shown in a tab like: fk, pk-s, unique, or others选项卡中未显示任何约束,例如:fk、pk-s、unique 或其他
  • no table or field completions in the editor编辑器中没有表格或字段完成
  • no functions, packages,triggers, views are shown没有显示函数、包、触发器、视图

The sad thing is Oracle should only change the queries behind this view in case of PostgreSql connections.可悲的是,Oracle 应该只在 PostgreSql 连接的情况下更改此视图背后的查询。 For example for indexes they need to use this query: select * from pg_catalog.pg_indexes;例如对于索引他们需要使用这个查询: select * from pg_catalog.pg_indexes;

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 用户名和数据库名称不同

host= localhost/postgres?主机=本地主机/postgres? worked for me if you need a schema/database use:如果您需要使用架构/数据库,则为我工作:

localhost/postgres?currentSchema=myschema localhost/postgres?currentSchema=myschema

ex: localhost/postgres?currentSchema=public例如:localhost/postgres?currentSchema=public

once connected, you can also use the [Choose Database] button and pull down连接后,您也可以使用 [Choose Database] 按钮并下拉

sql developer postgres jdbc url for the rest of us sql 开发人员 postgres jdbc url 用于我们的 Z65E8800B5C6800AAD896F888B2A6A6A

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM