0

What is the actual difference between the following 2 declarations of JDBC URL?

1. jdbc:oracle:thin:@//hostname:1521/servicename

2. jdbc:oracle:thin:@hostname:1521:sidid

Reason for the question: URL1 works for only for some specific oracle database whereas URL2 seems to work for all types of data. Can the URL2 format be used for the servicename also?

Issue: I got the following error when I used URL1 against certain database.

java.sql.SQLException: Listener refused the connection with the following error:
ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
The Connection descriptor used by the client was:
//hostname:1521/sidid

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:280)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:328)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:361)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:151)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:595)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)

Solution: Used URL2 and it fixed the above TNS error.

Edited: Changed the format of the URL to servicename from sid. Why it is throwing an error when just the format its expecting for a sid is different from service?

raksja
  • 3,969
  • 5
  • 38
  • 44

0 Answers0