I am confused with the URL we provide to create JDBC connection.

Lets say there are 2 databases available i.e., DB1 (IP1), DB2 (IP2).

Oracle Listener is configured to point to DB2 (lets say the SID is MYDB). [SID --> DB2]

Now while creating connetion if I mention IP1 and MYDB as SID, I can still connect successfully but further query to any table throws exception.


Now my question is since we are using SID to create the connection which is already pointing to a IP in listener then why we need to mention the IP again to create Connection object as shown above.

Any clarity will be greately appreciated.

Thanks a lot.

Best Regards - Roy