Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.3K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 545 SQLcl
- 4K SQL Developer Data Modeler
- 187K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 440 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

Hello Everybody,.
I would like to know,what am I missing here...
I have the following Java code
/**
* Connect to Oracle Database.
*/
private static void oracleConnect() {
Connection conn = null;
try {
//Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl", "scott",
"Scott123");
System.out.println("Connected to the Oracle database...");
} /*catch (ClassNotFoundException e) {
e.printStackTrace();
} */catch (SQLException e) {
e.printStackTrace();
} finally {
try {
conn.close();
System.out.println("Connection closed...");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Exception:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:412)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.facebook.www.javagroup.GenericTaskInterpreter.oracleConnect(GenericTaskInterpreter.java:53)
at com.facebook.www.javagroup.GenericTaskInterpreter.main(GenericTaskInterpreter.java:27)
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
All my oracle services are running fine and I am also able to login as user scott.My Oracle version is: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
Any help would be appreciated.Thanks in advance.
Answers
-
post results from the following two OS commands:
lsnrctl status
lsnrctl service
Since every connection request to the listener gets logged, listener.log file will contain a line with 12505 as status code.
*This line contains valuable debugging details. So post this line & surrounding lines.*
for additional debugging suggestions read the URL below:
http://edstevensdba.wordpress.com/2011/03/19/ora-12514/
[[email protected] ~]$ oerr ora 12505
12505, 00000, "TNS:listener does not currently know of SID given in connect descriptor"
// *Cause: The listener received a request to establish a connection to a
// database or other service. The connect descriptor received by the listener
// specified a SID for an instance (usually a database instance) that either
// has not yet dynamically registered with the listener or has not been
// statically configured for the listener. This may be a temporary condition
// such as after the listener has started, but before the database instance
// has registered with the listener.
// *Action:
// - Wait a moment and try to connect a second time.
// - Check which instances are currently known by the listener by executing:
// lsnrctl services <listener name>
// - Check that the SID parameter in the connect descriptor specifies
// an instance known by the listener.
// - Check for an event in the listener.log file.
-
Thanks sb92075 for the quick response.
FYI Please...
a) lsnrctl status
Output:
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 05-NOV-2013 21:07:55
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ
ction
Start Date 05-NOV-2013 18:41:18
Uptime 0 days 2 hr. 26 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File
\app\Sandeep\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File d:\app\sandeep\diag\tnslsnr\Sandeep-PC\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 3 handler(s) for this service...
The command completed successfully
b)lsnrctl service
Output:
LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 05-NOV-2013 21:10:34
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 3 handler(s) for this service...
Handler(s):
"DEDICATED" established:0 refused:0
LOCAL SERVER
"ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready
CLRExtProc
(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\NTN_E5C_373D2E46.ORA))
"ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready
CLRExtProc
(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\NTN_E5C_373D2E46.ORA))
The command completed successfully
-
sandeep.c wrote: Thanks sb92075 for the quick response. FYI Please... a) lsnrctl status Output: LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 05-NOV-2013 21:07:55 Copyright (c) 1991, 2010, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ ction Start Date 05-NOV-2013 18:41:18 Uptime 0 days 2 hr. 26 min. 37 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File
\app\Sandeep\product\11.2.0\dbhome_1\network\admin\listener.ora Listener Log File d:\app\sandeep\diag\tnslsnr\Sandeep-PC\listener\alert\log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) Services Summary... Service "CLRExtProc" has 1 instance(s). Instance "CLRExtProc", status UNKNOWN, has 3 handler(s) for this service... The command completed successfully b)lsnrctl service Output: LSNRCTL for 64-bit Windows: Version 11.2.0.1.0 - Production on 05-NOV-2013 21:10:34 Copyright (c) 1991, 2010, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) Services Summary... Service "CLRExtProc" has 1 instance(s). Instance "CLRExtProc", status UNKNOWN, has 3 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 LOCAL SERVER "ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready CLRExtProc (ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\NTN_E5C_373D2E46.ORA)) "ORACLE SERVER" established:0 refused:0 current:0 max:25 state:ready CLRExtProc (ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\NTN_E5C_373D2E46.ORA)) The command completed successfully
So now you have to ask yourself, "why doesn't my listener know about 'orcl'?"
Two reasons come immediately to mind:
1) this listener isn't on the server where your 'orcl' instance is running
2) this listener IS on the same server, but the 'orcle' instance is NOT running
3) this listener IS on the same server, the 'orcle' instance IS running, but an incorrectly set LOCAL_LISTENER parameter prevents it from registering with the listener.
BTW, your listener is configured to listen on IP address 127.0.0.1. This absolutely guarantees that it will never receive a connection request that originates from any other box.
-
I am running this code on my Laptop.
What really annoys me is that this code snippet worked before.I formatted my system and re-installed Oracle and now this exception.
I am sorry if this sounds stupid.
-
sandeep.c wrote: I am running this code on my Laptop. What really annoys me is that this code snippet worked before.I formatted my system and re-installed Oracle and now this exception. I am sorry if this sounds stupid.
So is the database running on your laptop? On the native OS - not a virtual machine?
You've been given several clues ... I've not seen anything indicating you've actually followed up on them.
-
is OS Service for the database been started & is now running?
is the database itself been started & is now online?
-
The database is installed on the native OS.All its services are running and as mentioned before I am able to login as user scott and sysdba.
I was going through your wordpress blog.and was looking at my tnsnames.ora file,the content given is as belows
# tnsnames.ora Network Configuration File:
\app\Sandeep\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
Still stuck -
the output from
lsnrctl status
would show any running database; which it does not for YOU!
see example from my system below
[[email protected] ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 05-NOV-2013 10:43:07
Copyright (c) 1991, 2010, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date 12-OCT-2013 20:40:43
Uptime 23 days 15 hr. 2 min. 24 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_2/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=80))(PROTOCOL_STACK=(PRESENTATION=HTTP)(SESSION=RAW)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=21))(PROTOCOL_STACK=(PRESENTATION=FTP)(SESSION=RAW)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 2 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[[email protected] ~]$
NOTICE that the Service "orcl" exists for my database
-
I can see that all Oracle services has started by doing a services.msc.(particularly OracleServiceORCL)
But when I run this from sqlplus as scott/Scott123
CONNECT scott/[email protected]
"TNS:listener does not currently know of SID given in connect descriptor"
Is that what you meant ? Looks like I am missing something basic.What do you suggest ?
-
sandeep.c wrote: I can see that all Oracle services has started by doing a services.msc.(particularly OracleServiceORCL) But when I run this from sqlplus as scott/Scott123 CONNECT scott/[email protected] "TNS:listener does not currently know of SID given in connect descriptor" Is that what you meant ? Looks like I am missing something basic.What do you suggest ?
earlier in this thread you posted the results from
lsnrctl status
that was run on your system.
It does NOT show "Service "orcl" has 1 instance(s)." since it does not know about any database named "orcl"
& this is consistent with the error message.
open a Command Window & do as below
lsnrctl stop
cd
\app\Sandeep\product\11.2.0\dbhome_1\network\admin\
ren listener.ora listener.ora.sav
lsnrctl start
lsnrctl status
# wait 60+ seconds before proceeding
lsnrctl service
COPY the results from above then PASTE all back here