database - Sql Developer 可以连接Oracle Database 12c 和TNS 但不能连接basic

标签 database oracle oracle-sqldeveloper oracle12c tnsnames

我已经安装了一个新的 oracle 数据库 (12.2.0.1)。我已经创建了一个可插入数据库 (orclpdb)。我在 PDB 中创建了一个用户 Fed_Test_User。我可以通过 SQL 开发人员将其连接到 TNS(可以通过 conn Fed_Test_User/welcome@orclpdb 连接)。但是我无法通过具有基本连接类型的 SQL Developer 进行连接。

监听器.ora:

 LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

sqlnet.ora:

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

tnsnames.ora:

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.us.oracle.com)
    )
  )


ORCLPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME =orclpdb.us.oracle.com)
    )
  )

lsnrctl 状态:

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                14-SEP-2018 20:38:13
Uptime                    0 days 2 hr. 46 min. 28 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /scratch/jxi/oracleDB/product/12c/db_1/network/admin/listener.ora
Listener Log File         /scratch/jxi/oracleDB/diag/tnslsnr/slc16vyj/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=slc16vyj.us.oracle.com)(PORT=5500))(Security=(my_wallet_directory=/scratch/jxi/oracleDB/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "75e0ec7d5ff26817e053f5e0f50a1fa4.us.oracle.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl.us.oracle.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.us.oracle.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclpdb.us.oracle.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

我错过了什么?希望可以有人帮帮我。谢谢;

最佳答案

连接到 PDB 时,必须使用 SERVICE 名称。

SID 仅适用于容器数据库。

enter image description here

See this page, specifically working with PDBs

Service Name. When you create a PDB, Oracle automatically adds it as a service in the listener. You can confirm it by looking at the listener status: 

[oracle@prosrv1 trace]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.1.0 - Production on 24-FEB-2013 12:20:14
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.1.0 - Production
Start Date 19-FEB-2013 21:09:05
Uptime 4 days 15 hr. 11 min. 9 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
/u02/app/oracle/product/12.1.0/grid/network/admin/listener.ora
Listener Log File
/u02/app/oracle/diag/tnslsnr/prosrv1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=prosrv1.proligence.com)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "CONA" has 1 instance(s).
Instance "CONA", status READY, has 1 handler(s) for this service...
Service "CONAXDB" has 1 instance(s).
Instance "CONA", status READY, has 1 handler(s) for this service...
Service "pdb1" has 1 instance(s).
Instance "CONA", status READY, has 1 handler(s) for this service...
The command completed successfully
The service "pdb1" actually points to the PDB called PDB1. It's very important to note that that this is not a service name in initialization parameter of the database, as you can see from the service_names parameter of the database.

SQL> show parameter service
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string CONA
You can place that service name in an entry in the TNSNAMES.ORA file:

PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = prosrv1.proligence.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PDB1)
)
)
Now you can connect to PDB1 using the connect string:

[oracle@prosrv1 ~]$ sqlplus system/oracle@pdb1

关于database - Sql Developer 可以连接Oracle Database 12c 和TNS 但不能连接basic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52342242/

相关文章:

oracle - Oracle 序列的 MAXVALUE 的用途是什么?

oracle - Flyway 自定义清洁脚本的可能性

甲骨文 : Export select statement result set as INSERT SQL Statements similar to SQL developer export

database - 本地DB抛出字节数组截断到长度为8000异常

mysql - 选择操作期间出现不明确的列名错误

SQL 查询以查找多个条件的匹配项

mysql - 不同且唯一的列值的总和

string - 在PLSQL中提取URL路径段字符串

database - Entity Framework 6 Code First 方法 - 唯一约束不起作用

MySQL迁移错误: Invalid timestamp literal detected