Home > JDBC, Oracle > ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

ORA-12505: TNS:listener does not currently know of SID given in connect descriptor

I am not sure why I get this error since I can connect to the current SID by using sqlplus but I cannot connect to it by using jdbc with the following url:

jdbc:oracle:thin:@aHost:1521:theSID

After searching for about an hour I found out that you can also use the full blown jdbc url protocol to connect to oracle

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=aHost) (PORT=1521))(CONNECT_DATA=(SERVICE_NAME=theSID)))

This does not explain why the issue happens but at least for now it solves the problem. I will post an update if I find anything else.

Categories: JDBC, Oracle
  1. Vishal
    20 October 2011 at 5:00 am

    Thanx. It is really helpful.

  2. test
    1 November 2011 at 7:44 pm

    Iam trying to connect iReropt to Oracle db using Database JDBC Connection wizard.
    I tried the same way as you mentioned and it works the same way it worked for you.
    i.e. when i mention the full blown jdbc url, it is connecting successfully, but not for jdbc:oracle:thin:@myHost:1521:mySID. Dont know why ??

  3. 1 November 2011 at 8:09 pm

    Not sure why it’s doing it. Maybe the application server does not like something in the URL. Not sure.

  4. tomim
    24 November 2011 at 11:28 am

    Hi,

    As I understand, you are using service name instead of SID.

    URL for conenctions based on service names should be in this format…
    jdbc:oracle:thin:@//aHost:1521/theSID

  5. Liju John
    21 December 2011 at 11:05 pm

    This was really helpful for me !! Thanks

  6. tester
    24 December 2011 at 4:35 am

    thabkyou .It works πŸ™‚

  7. Uzay Ordu
    7 February 2012 at 12:21 pm

    Panos and tomim!

    Thank you very much

  8. Labrini
    19 February 2012 at 3:45 am

    Dear Panos,

    Thank you for the information.
    I have the same message in my PC while I try to connect SQL developer with the Oracle database.
    Do you know where to make this change of JDBC driver?

    Thank you,
    Labrini

  9. 20 February 2012 at 7:37 am

    Hi Labrini, you should put the full URL in the field where you define the format of the jdbc url protocol. Not sure where exactly this is, I have never used SQL Developer. Have a look at the SQL Developer documentation for more information.

  10. jetcracker
    28 February 2012 at 8:03 pm

    Interesting. I’ve never had such error. A simple connection string always worked for me.

  11. 7 March 2012 at 12:00 pm

    plz tell me what i use insted of SID?

  12. Lavanya
    24 March 2012 at 8:00 am

    No luck 😦 , Tried out all the three options below to connect to the Oracle10g XE but getting the same exception ORA-12514 :

    1.jdbc:oracle:thin:@localhost:1521:TelusDB
    2.jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TelusDB)))
    3.jdbc:oracle:thin:@localhost:1521:TelusDB

    where TelusDB is the DB name i created in Oracle.

  13. Lavanya
    24 March 2012 at 8:01 am

    sry, correction to the third option above :
    3. jdbc:oracle:thin:@//localhost:1521/TelusDB
    😦 😦 😦
    Help pls

  14. oracle_user
    3 June 2012 at 5:40 pm

    thanks–it really helped

  15. Pieter
    4 June 2012 at 7:10 pm

    Life saver, took me hours finding out how to fix this

  16. Suresh Mopada
    5 July 2012 at 8:03 pm

    Hi, I am Suresh Mopada. I had the same problem but its resolved for me.

    i am using window 7 64 bit operating system and oracle 10 g.
    while try to connect oracle database (database SID: orcl, username: system, password: manager) using jdbc type 4 driver (thin). i got the error ORA:12505.
    i found all tns entries are correct and listener also running.. but still i got the error due to the
    statement which i used in JDBC program.

    old type !V driver syntax:
    try{
    Class.forName(“oracle.jdbc.driver.OracleDriver”);
    Connection con = DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:XE”,”system”,”manager”);
    System.out.println(con);
    }catch(Exception e)
    {
    e.printStackTrace();
    }
    O/P causes the ORA:12505 error.

    in windows 7 64 bit operating system the above code not worked for me. so i change the JDBC code see below.

    New code:

    try{
    Class.forName(“oracle.jdbc.driver.OracleDriver”);
    Connection con = DriverManager.getConnection(“jdbc:oracle:thin:@localhost:1521:orcl”,”system”,”manager”);
    System.out.println(con);
    }catch(Exception e)
    {
    e.printStackTrace();
    }

    Note: you have to mention your SID in the Connection string. in my scenario orcl is my SID, at the time oracle installation i given that name.

    O/P oracle.jdbc.driver.T4CConnection@b169f8

    I hope it will help you.

    if you have any queries, you can reach me on sureshm1986@gmail.com

    • Diwakar
      24 January 2016 at 3:16 pm

      I have tried exactly like that
      previously it is working for me, but suddenly its not working for me.
      I am giving exactly the same thing.
      iam using oracle 12c.
      i have also crosschecked the tnsnames.ora file generated by oracle.
      SID is orcl.
      don’t know why it is happening.
      I have checked my listener status too through cmd, don’t know what others option i have.

  17. felippe
    7 November 2012 at 12:07 pm

    Guy, you saved my life ! haha, thank you !

  18. Ashook
    28 November 2012 at 12:36 pm

    A big Thank to Panos. It worked.

  19. frits
    6 August 2013 at 12:18 pm

    Thanks, you saved my day! πŸ˜€

  20. Chloe chong
    3 March 2014 at 12:38 pm

    There are another solution for ora-12505, if you are using windows you can just run msconfig and find your SID and change it then the problems should be solved. For more details you can visit http://blackandwhitecomputer.blogspot.com/2013/11/error-ora-12505-oracle-sql-developer.html

  21. John Ortiz
    14 September 2014 at 9:59 pm

    Thanks @Panos. I was needing how to specify the the SID value in connection string in iReport:

    jdbc:oracle:thin:@ServerName:Port:SID

  22. PixnBits
    26 March 2015 at 6:45 pm

    Thanks for saving me an hour πŸ™‚

  23. 25 September 2015 at 4:51 pm

    Thank you very much Panos

  1. 3 September 2011 at 4:04 am

Leave a comment