7

I wanted to know can we use both colon and forward slash with SID in making the connection URL in Oracle?

e.g.

jdbc:oracle:thin:@<host>:1521:<SID>
jdbc:oracle:thin:@<host>:1521/<SID>

Will these two are same and will work?

I am building an application which will work with both Oracle RAC and non RAC environments and RAC environments supports SERVICE NAME with forward slash so wanted to check will non RAC environment support forward slash .

For RAC environment URL is like this

jdbc:oracle:thin:@<host>:1521/<SERVICENAME>

Update This is different question because i want to ask is it possible to use both (: and / while using <SID> in the connection String which we call as OracleJDBCUrl .

Deepak Jain
  • 305
  • 1
  • 3
  • 19
  • @JSapkota so it means with in `non RAC` we can use both colon and forward slash if SQL Developer is saying connection established and status is success? – Deepak Jain May 10 '17 at 06:48
  • However, if I try to connect from Java, '/' is used for service name and ':' is used for SID. – atokpas May 10 '17 at 07:06
  • 1
    [Java JDBC - How to connect to Oracle using Service Name instead of SID](http://stackoverflow.com/questions/4832056/java-jdbc-how-to-connect-to-oracle-using-service-name-instead-of-sid) – atokpas May 10 '17 at 07:18
  • @JSapkota can i use anything(between colon and slash) while using the ? – Deepak Jain May 10 '17 at 07:25
  • @DeepakJain This isn't a URL. It's a JDBC connection string. It's syntax is defined in the documentation. JSapkota already provided a link to a duplicate answer *and* the docs. Why do you want to use `/SID` when you see that the syntax is `:SID` ? – Panagiotis Kanavos May 10 '17 at 08:30
  • Possible duplicate of [Java JDBC - How to connect to Oracle using Service Name instead of SID](http://stackoverflow.com/questions/4832056/java-jdbc-how-to-connect-to-oracle-using-service-name-instead-of-sid) – Panagiotis Kanavos May 10 '17 at 08:31
  • 1
    @PanagiotisKanavos I want to use because I'm able to connect to the DB by using `/` also so which one is correct, I am stuck to that point. and URL i meant for the `OracleJDBCURL`. – Deepak Jain May 10 '17 at 08:58

4 Answers4

5

I've used both colon : and forward slash / for SID in connection URL and was able get the connection established. I think in Oracle 11g to connect with a Service Name, we can only use the forward slash / .

zb226
  • 9,586
  • 6
  • 49
  • 79
Deepak Jain
  • 305
  • 1
  • 3
  • 19
1

We recommend to use the long form of the connection URL as show below.

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename)))

Check out DataSourceSample and UCPSample for reference.

Nirmala
  • 1,278
  • 1
  • 10
  • 11
1

Both SID and ServiceName works for me using only "/". I'm using Java.sql.Connection on windows server, I'm not sure if it works on Linux.

jdbc:oracle:thin:@<host>:<port>/<SERVICENAME or SID>
cokekutu
  • 41
  • 3
0

jdbc:oracle:thin:@//HOSTNAME:PORT/SERVICENAME

for instance:

jdbc:oracle:thin:@//10.80.12.162:1624/xyzabc
Muhammad Saimon
  • 233
  • 2
  • 10