How to connect to Oracle using Service Name instead of SID

+2 votes

I have a Java application that uses JDBC (via JPA) that was connecting to a development database using hostname, port and Oracle SID. But is there other way to connect to Oracle using Service Name?

Jun 27, 2018 in Java by Daisy
• 8,140 points
10,031 views

2 answers to this question.

0 votes

Thin-style service names are supported only by the JDBC Thin driver. The syntax is:

@//host_name:port_number/service_name
jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL=TCP)(HOST=blah.example.com)(PORT=1521)))(CONNECT_DATA=(SID=BLAHSID)(GLOBAL_NAME=BLAHSID.WORLD)(SERVER=DEDICATED)))
answered Jun 27, 2018 by sharth
• 3,370 points
0 votes

HII..

I hope this information may help you-

Thin-style Service Name Syntax

Thin-style service names are supported only by the JDBC Thin driver. The syntax is:

@//host_name:port_number/service_name

For example:

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

answered Sep 29, 2020 by SRI

Related Questions In Java

0 votes
1 answer

How to get the name of the currently executing method?

Thread.currentThread().getStackTrace() will usually contain the method you’re ...READ MORE

answered Jul 5, 2018 in Java by Daisy
• 8,140 points
809 views
+1 vote
1 answer

How to print factorial of a number using While loop?

While also works like for just you ...READ MORE

answered Nov 22, 2018 in Java by Namitha
1,307 views
+1 vote
1 answer

How to get Alias name of AWS Lambda function from java code?

Hey @Abhishek, you could probably use the ...READ MORE

answered Apr 1, 2020 in Java by Sirajul
• 59,230 points
2,165 views
0 votes
3 answers

How to read input from Console using Scanner Class?

A simple example: import java.util.Scanner; public class Expl { ...READ MORE

answered Aug 1, 2018 in Java by samarth295
• 2,220 points
5,046 views
–1 vote
1 answer

What is the difference between oracle JDK and open JDK

Both OpenJDK and Oracle JDK are created ...READ MORE

answered Jul 10, 2018 in Java by Akrati
• 3,190 points
1,070 views
+1 vote
2 answers

How to prepare for Oracle Certified Associate Java Programmer Exam?

Join an Online Course  As I would like ...READ MORE

answered Sep 9, 2019 in Career Counselling by Sirajul
• 59,230 points
1,292 views
0 votes
1 answer

java.sql.SQLException: - ORA-01000: maximum open cursors exceeded

The maximum-open-cursors error, also known as ORA-01000, ...READ MORE

answered Sep 11, 2022 in Database by narikkadan
• 63,720 points

edited Jul 5, 2023 by Khan Sarfaraz 3,491 views
0 votes
1 answer
0 votes
1 answer

How to get the IP address of the machine using Java?

One approach is to use NetworkInterface.getNetworkInterfaces() to get all ...READ MORE

answered Jun 25, 2018 in Java by sharth
• 3,370 points
948 views
0 votes
1 answer

How to convert a string representation of a hex dump to a byte array using Java?

public static byte[] hexStringToByteArray(String s) { ...READ MORE

answered Sep 26, 2018 in Java by sharth
• 3,370 points
2,057 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP