Navicat Oracle 12514: 解决Oracle数据库连接错误
在使用Navicat连接Oracle数据库时,可能会遇到"ORA-12514: TNS:listener does not currently know of service requested in connect descriptor"的错误。这通常发生在连接Oracle数据库时,所连接的服务名称不正确或者listener没有加载正在尝试连接的服务名称。那么,如何解决这个问题呢?
解决问题的第一步是确认连接信息是否正确,比如用户名、密码、主机名、端口号和服务名称等等。如果这些信息不正确,连接Oracle数据库时必然会失败。对于服务名称的确认,可通过sqlplus在服务器端执行命令"lsnrctl status"查看。
如果确认连接信息一切正常,而Navicat连接Oracle时还是出现了"ORA-12514"错误,那么很有可能是listener没有加载正在尝试连接的服务名称,需要手动将服务名称加入到listener.ora文件中。
修改listener.ora文件的位置如下:
Unix/Linux系统:$ORACLE_HOME/network/admin/listener.ora
Windows系统:%ORACLE_HOME%\network\admin\listener.ora
下面是一个例子:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =)(PORT = 1526))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME =)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)
)
)
在SID_LIST_LISTENER节点下新增一个SID_DESC节点,把服务名称加入到SID_NAME节点里面。
下面是一个修改后的例子:
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST =)(PORT = 1526))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME =)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)
)
(SID_DESC =
(SID_NAME =)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/dbhome_1)
)
)
修改后,需要重启listener:
Unix/Linux系统:$ lsnrctl stop
$ lsnrctl start
Windows系统: C:\>lsnrctl stop
C:\>lsnrctl start
重新连接Navicat,问题就会得到解决。
总结起来,Navicat连接Oracle时出现"ORA-12514"错误,可能是服务名称不正确或者listener没有加载正在尝试连接的服务名称。解决这个问题需要确认连接信息的正确性,并手动将服务名称加入到listener.ora文件中。