Oracle

SQL Developer 無法連接 Oracle 數據庫,但 sqlplus 可以!

  • September 21, 2017

我在將 sql developer 連接到我的 Oracle 10g 數據庫時遇到問題。sqlplus 可以正常連接,但是當我嘗試在 sql developer 中打開連接時,出現“ORA-12514 TNS 不知道服務”錯誤。我嘗試修改我的 tnsnames.ora 文件。它具有以下內容:

COTT3 = 
(DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 (CONNECT_DATA = 
  (SERVER = DEDICATED)
  (SERVER_NAME = COTT3)
 )
)

誰能協助我可能需要修改的任何其他文件或讓我知道我哪裡出錯了?

謝謝

更新 lsnrctl 狀態的輸出

[oracle@VM-COT-DEV1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 02-FEB-2012 13:57:20

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                02-FEB-2012 13:01:25
Uptime                    0 days 0 hr. 55 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /opt/oracle/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
 (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
 Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

enter code here

嘗試這個:

COTT3 = 
(DESCRIPTION =
 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 (CONNECT_DATA = 
  (SERVER = DEDICATED)
  (SERVICE_NAME = COTT3)
 )
)

如果這不起作用,請將“SERVICE_NAME”替換為“SID”。

把它放在 $ORACLE_HOME/network/admin/listener.ora 中:

LISTENER =
 (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS_LIST =
       (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
     )
   )
 )

SID_LIST_LISTENER =
(SID_LIST =
   (SID_DESC =
     (SID_NAME = COTT3)
         (ORACLE_HOME = /opt/oracle/oracle/product/10.2.0/db_1 )
   )
 )

然後使用以下命令重新啟動偵聽器:

lsnrctl reload

您是否 100% 確定數據庫已啟動?

做:

ps auxww | grep pmon | grep -i cott3

…產生任何輸出?

引用自:https://dba.stackexchange.com/questions/12098