I am connecting to Oracle 11g DB trough my java program. I am using Service Name and not SID.
addr = jdbc:oracle:thin:@hostIP:1521:ServiceName
Class.forName("oracle.jdbc.OracleDriver");
Connection con = DriverManager.getConnection(addr,un,pw);
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery(SELECT * from Table);
This works great. I am able to connect to DB and retrieve the data.
However, if I pass Service ID instead of Service Name, code doesn't work! I get exception. I tried solution mentioned here - Java JDBC - How to connect to Oracle using Service Name instead of SID. But i still see the same exception.