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);
.
.
.
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
String username = "testuser";
String password = "testpassword";
con = DriverManager.getConnection(url, username, password);
.
.
.
Last edited: