I am trying to connect to Oracle (11.2.0.2.0) database using the Oracle JDBC thin driver(ojdbc6.jar for 11.2.0.2.0) and the following JDBC URL syntax:
jdbc:oracle:thin:@abcd
where 'abcd' is defined in my tnsnames.ora file as shown below:
abcd, abcd.world, abcd.dk.xyz.com =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = abcd.dk.xyz.com)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = abcd)
)
)
I have provided the VM option -Doracle.net.tns_admin=/etc/tnsnames.ora
as per Oracle® Database JDBC Developer's Guide and Reference.
I am getting the following error when I run the application:
Listener refused the connection with the following error:
ORA-12504, TNS:listener was not given the SID in CONNECT_DATA
But when I remove the aliases abcd.world and abcd.dk.xyz.com from tnsnames.ora, my application is able to connect to the database.
Is there an issue with ojdbc driver when there are multiple aliases in tnsnames.ora file?
My JDK version is 1.6.0_31.
Thanks, VJ
-Doracle.net.tns_admin=/etc
. Also note that database cluster might have more than one hostname plus there are dozens of connection parameters DBAs might want to setup. tnsnames.ora really should be prefered way. JDBC urls are too "stupid". – ibre5041