Oracle SID or Service Name

Fuma

Executive Member
Joined
Jul 9, 2007
Messages
5,378
Reaction score
361
Location
Pretoria
What's the difference between an SID and Service Name?

My Oracle's tnsnames.ora file has the following:

DB1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.xxx.xx.xx)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = sdb1)
)
)

DB2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.xxx.xx.xxx)(PORT = 1521))
)
(CONNECT_DATA =
( SID =sdb2)
)
)


I am using Java servlet to connect to either of the two databases.
I get an error (I don't remember what error it is) when I use SID, but it works fine when I used SERVICE_NAME.
I can connect to both databases using TOAD or PL/SQl Developer.
Here is the code:
.
.
.
Class.forName("oracle.jdbc.driver.OracleDriver");

String serverName = "10.xxx.xx.xx";
String portNumber = "1521";
String service_name = "sdb1"; // but sdb2 doesn't work
String url = "jdbc: oracle:thin:@" + serverName + ":" + portNumber + ":" + service_name;
String username = "testuser";
String password = "testpassword";
con = DriverManager.getConnection(url, username, password);

.
.
.
 
Last edited:
Cant give exact details but SID is the old method of connecting to Oracle DBs and they use service names instead. Mainly due to new data guard implementations etc. Oracle started to enforce service names and strict enforcements of java connect strings to accommodate this.
 
Cant give exact details but SID is the old method of connecting to Oracle DBs and they use service names instead. Mainly due to new data guard implementations etc. Oracle started to enforce service names and strict enforcements of java connect strings to accommodate this.

So I cannot connect to DB2? Or there another way to connect to it without having to work on the DB server itself?
 
Top
Sign up to the MyBroadband newsletter
X