ORA-12505: TNS:listener could not resolve SID given in connect descriptor

    You are trying to connect to a database, but the SID is not known.

    Although it is possible that a tnsping command succeeds, there might still a problem with the SID parameter of the connection string.

    eg.
    C:>tnsping ora920
    
    TNS Ping Utility for 32-bit Windows: Version 9.2.0.7.0 - Production 
    
    Copyright (c) 1997 Oracle Corporation.  All rights reserved.
    
    Used parameter files:
    c:\oracle\ora920\network\admin\sqlnet.ora
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = DEV01)(PORT =
     2491))) (CONNECT_DATA = (SID = UNKNOWN) (SERVER = DEDICATED)))
    OK (20 msec)
    
    As one can see, this is the connection information stored in a tnsnames.ora file:
    ORA920.EU.DBMOTIVE.COM =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = DEV01)(PORT = 2491))
        )
        (CONNECT_DATA =
          (SID = UNKNOWN)
          (SERVER = DEDICATED)
        )
      )
    
    However, the SID UNKNOWN is not known by the listener at the database server side.
    In order to test the known services by a listener, we can issue following command at the database server side:
    C:>lsnrctl services
    
    LSNRCTL for 32-bit Windows: Version 10.1.0.2.0 - Production 
    
    Copyright (c) 1991, 2004, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DEV01)(PORT=1521)))
    Services Summary...
    Service "ORA10G.eu.dbmotive.com" has 1 instance(s).
      Instance "ORA10G", status UNKNOWN, has 1 handler(s) for this service...
        Handler(s):
          "DEDICATED" established:0 refused:0
             LOCAL SERVER
    Service "ORA920.eu.dbmotive.com" has 2 instance(s).
      Instance "ORA920", status UNKNOWN, has 1 handler(s) for this service...
        Handler(s):
          "DEDICATED" established:0 refused:0
             LOCAL SERVER
      Instance "ORA920", status READY, has 1 handler(s) for this service...
        Handler(s):
          "DEDICATED" established:2 refused:0 state:ready
             LOCAL SERVER
    The command completed successfully
    
    Know services are ORA10G and ORA920.

    Changing the SID in our tnsnames.ora to a known service by the listener (ORA920) solved the problem.

Adverteren bij Daisycon
Forum Messages
02-APR-2008 09:31:04 Listener refusing the connectionJoseph Padamadan Reply
hi
i have worte a java stored procedure for oracle database.
when i executed it i got the following error.
"java.sql.SQLException: Listener refused the connection with the following error:

ORA-12505, TNS:listener does not currently know of SID given in connect descript
or
The Connection descriptor used by the client was:
192.168.1.2:1521:heads"
heads is the name of database
any one help me.
: ->  02-APR-2008 13:09:17Values requiredDbMotive Reply
Can you please post the outcome of following select statement?


select name, value
from v$parameter
where name in ('db_name', 'db_domain', 'service_names')


03-APR-2008 09:23:39joseph Reply
outcome is
NAME
------------------------
VALUE
------------------------
db_domain


service_names
zeno

db_name
zeno
: ->  03-APR-2008 09:39:10Incorrect database nameDbMotive Reply
Your database is called zeno, but you connect to the heads database.

Change your connect string into:

192.168.1.2:1521:zeno



03-APR-2008 10:02:20joseph Reply
i have changed the sid as zeno.then i got this
--------------------------------------------------------------------------------
java.sql.SQLException: statement handle not executed
: ->  03-APR-2008 10:29:19Please post codeDbMotive Reply
Can you post the piece of code you use to connect to the database?

We suspect there's something wrong with the connection routine.
04-APR-2008 07:09:42josephpadamadan Reply
here is the code:

import java.sql.*;
import oracle.jdbc.*;
public class Countries {
public static String getCountry(String id) {
String s=null;
Connection conn=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String serverN="DEVSERVER";
String portNum="1521";
String sid="zeno";
String url="jdbc:oracle:thin:@"+serverN+":"+portNum+":"+sid;
conn =DriverManager.getConnection(url,"heads","heads");
PreparedStatement pstmt = conn.prepareStatement(
"SELECT NAME FROM KRM_COUNTRY WHERE ID=?");
pstmt.setString(1,id);
ResultSet rSet=pstmt.executeQuery();
pstmt.close();
s=rSet.getString("NAME");
conn.close();
}catch(Exception e) {
s=e.toString();
}
return s;
}
}
Add your message for ORA-12505
Name:email:
Validation Code:zbu0fcqscrtyqkone
Enter Code above:
Title:
State your problem: