Java ORA-12514: TNS:listener 当前不知道连接描述符中请求的服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21553557/
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
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
提问by watson94
I have problem, when trying to connect to Oracle Database XE via listener:
我在尝试通过侦听器连接到 Oracle 数据库 XE 时遇到问题:
sqlplus system/my_password@XE
I get the following error:
我收到以下错误:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
I use Ubuntu 12.10 and Oracle Express Edition 11g.
我使用 Ubuntu 12.10 和 Oracle Express Edition 11g。
My main goal to connect java + oracle db with jdbc, but there i get the same error.
我的主要目标是将 java + oracle db 与 jdbc 连接起来,但是我遇到了同样的错误。
Here are my listener.ora
这是我的听众.ora
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
and tnsnames.ora
和 tnsnames.ora
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = watson)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
and
和
lsnrctl service
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 04-FEB-2014 17:01:44
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
The command completed successfully
采纳答案by Alex Poole
Assuming your database is failing to register even when the listener has been running for a while, it sounds like your local_listener
parameter isn't explicitly set, so your database is trying to register on a default address; and since it's failing to register, whatever address it's using doesn't seem to be the same one the listener is on.
假设您的数据库即使在侦听器运行了一段时间后也无法注册,听起来您的local_listener
参数没有明确设置,因此您的数据库正在尝试在默认地址上注册;并且由于它无法注册,因此它使用的任何地址似乎都与侦听器所在的地址不同。
Assuming watson
is resolving to a useful external IP address, which is probably the case if you're able to get that TNS error from outside your box, you can tell the database to use the same address to register:
假设watson
正在解析一个有用的外部 IP 地址,如果您能够从您的机器外部获得该 TNS 错误,可能就是这种情况,您可以告诉数据库使用相同的地址进行注册:
alter system set local_listener = '(ADDRESS=(PROTOCOL=TCP)(HOST=watson)(PORT=1521))' scope=memory;
alter system register;
If that works and lsnrctl services
now shows XE
and you're happy with it, you can change the memory
to both
and re-execute so it persists across the next DB restart.
如果这有效并且lsnrctl services
现在显示XE
并且您对它感到满意,您可以更改memory
toboth
并重新执行,以便它在下一次 DB restart 中保持不变。
Alternatively, if you've only tried connecting within the same box, watson
might be resolving to something unhelpful, like 127.0.0.1 if it's set to do that in your /etc/hosts
; or your /etc/hosts
address might not agree with your DNS entry. You can change the listener.ora
and tnsnames.ora
to the 'right' FQDN or IP address instead, as long as that matches whatever your database thinks is the network name.
或者,如果您只尝试在同一个框中进行连接,则watson
可能会解决一些无用的问题,例如 127.0.0.1,如果它在您的/etc/hosts
; 或者您的/etc/hosts
地址可能与您的 DNS 条目不一致。您可以改为将listener.ora
和更改为tnsnames.ora
“正确”的 FQDN 或 IP 地址,只要它与您的数据库认为的网络名称相匹配即可。
回答by tom87416
The tnsnames.ora is fine, it is used for the sqlplus client. The listener.ora is not good. You are missing the XE service when you type lsnrctl service Hard to believe you have to setup listener.ora to install Oracle express.
tnsnames.ora 很好,用于sqlplus 客户端。listener.ora 不好用。当您键入 lsnrctl service 时,您会错过 XE 服务 很难相信您必须设置 listener.ora 才能安装 Oracle express。
Here is a example from my testing VM.
这是我的测试 VM 中的示例。
Service "PEXPROC" has 1 instance(s).
Instance "PEXPROC", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
Service "ocmdb" has 1 instance(s).
Instance "ocmdb", status UNKNOWN, has 1 handler(s) for this service...
Handler(s):
"DEDICATED" established:29 refused:0
LOCAL SERVER
The command completed successfully
My sample segment in listener.ora
我在 listener.ora 中的示例片段
SID_LIST_LISTENER_OCM =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ocmdb)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = ocmdb)
)
)
回答by Brandon Stanley
I had to restart my OracleServiceXE service in windows services and it was working again.
我不得不在 Windows 服务中重新启动我的 OracleServiceXE 服务,它又可以正常工作了。