• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dataBase connection URL formation

 
alex russo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one please explain me the difference between the following two ways of forming a connection URL:

1)
String url_connection = null;
url_connection = "jdbc: oracle:thin:@" + context.Oracle_Server + ":"+ context.Oracle_Port + ":" + context.Oracle_ServiceName;

aganist

2)
String url_connection = null;
url_connection = "jdbc: oracle:thin:@(description=(address=(protocol=tcp)(host="+ context.Oracle_Server+ ")(port="+ context.Oracle_Port+ "))(connect_data=(service_name="+ context.Oracle_ServiceName + ")))";


and how is 2 different than jdbc: oracle:thin:@//<host>:<port>/<service_name>

thanks in advance for helping me with this.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the part after the "@" is entirely up to the driver to interpret. So if the Oracle driver accepts multiple ways of specifying the parameters, then you can use whichever format suits you best.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this particular example, the two URLs probably work the same. However, the second format allows you to specify additional connection parameters, such as load balancing, failover mode and so on. All of the options of the second format, which is known as "connect descriptor", can be found here.

Edit: our Oracle FAQ has a link that explains the syntax of the first format. You'll see that there is a difference between specifying the service name or SID.

 
alex russo
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Format 1 , even thou when I give Service_name it interprets it as SID and the possible reason could be the usage of ':'

Format 2: when I am trying to do '/'
jdbc: oracle:thin:@//<host>:<port>/<service_name>
for some reason it still thinks it as SID and not Service_name.
it requires explicitly to provide the description, host, connect data (format) for it to consider it as Service_Name.

Any idea why ?


Some online link that I cam across that explains the meaning of ':' and '/'
http://www.razorsql.com/articles/oracle_jdbc_connect.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic