0
votes

I am getting the exception ORA-12504, TNS:listener was not given the SID in CONNECT_DATA Could you please help me on this what went wrong? tnsnames.ora

SUNRISEDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = SUNRISEDB)
    )
  )

listener.ora

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = pacdcinfoddpodbc.cable.comcast.com)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = C:\app\kkumar003c

and my java code is

try {
                Class.forName("oracle.jdbc.driver.OracleDriver");
                 dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521","KIRANDB","KIRANDB"); 
                System.out.println();
            } catch (Exception e) {
                e.printStackTrace();
            }
        System.out.println("db connection=="+dbConn);
        }
2

2 Answers

1
votes

Change this line -

dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521","KIRANDB","KIRANDB");

to

dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521:**SUNRISEDB**","KIRANDB","KIRANDB");
0
votes

You need your schema name in the place of NAME.

dbConn = DriverManager.getConnection("jdbc:oracle:thin:@147.191.10.119:1521:NAME","KIRANDB","KIRANDB");