Java JDBC - How to connect to Oracle using Service Name instead of SID -


i have java application uses jdbc (via jpa) connecting development database using hostname, port , oracle sid, this:

jdbc:oracle:thin:@oracle.hostserver1.mydomain.ca:1521:xyz

xyz oracle sid. need connect different oracle database not use sid, uses oracle "service name" instead.

i tried doesn't work:

jdbc:oracle:thin:@oracle.hostserver2.mydomain.ca:1522:abcd

abcd service name of other database.

what doing wrong?

http://download.oracle.com/docs/cd/b28359_01/java.111/b31224/urls.htm#beidhcba

thin-style service name syntax

thin-style service names supported jdbc thin driver. syntax is:

@//host_name:port_number/service_name

for example:

jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename

so try:

jdbc:oracle:thin:@//oracle.hostserver2.mydomain.ca:1522/abcd


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -