Java JDBC - How to connect to Oracle using Service Name instead of SID
2015-02-23 16:51
429 查看
I have a Java application that uses JDBC (via JPA) that was connecting to a development database using hostname, port and Oracle SID, like this:
jdbc:oracle:thin:@oracle.hostserver1.mydomain.ca:1521:XYZ
XYZ was the Oracle SID. Now I need to connect to a different Oracle database that does not use a SID, but uses an Oracle "Service Name" instead.
I tried this but it doesn't work:
jdbc:oracle:thin:@oracle.hostserver2.mydomain.ca:1522:ABCD
ABCD is the Service Name of the other database.
What am I doing wrong?
Answers
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA
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
So I would try:
jdbc:oracle:thin:@//oracle.hostserver2.mydomain.ca:1522/ABCD
jdbc:oracle:thin:@oracle.hostserver1.mydomain.ca:1521:XYZ
XYZ was the Oracle SID. Now I need to connect to a different Oracle database that does not use a SID, but uses an Oracle "Service Name" instead.
I tried this but it doesn't work:
jdbc:oracle:thin:@oracle.hostserver2.mydomain.ca:1522:ABCD
ABCD is the Service Name of the other database.
What am I doing wrong?
Answers
http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/urls.htm#BEIDHCBA
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
So I would try:
jdbc:oracle:thin:@//oracle.hostserver2.mydomain.ca:1522/ABCD
相关文章推荐
- Tomcat上配置连接池{ connect error=Name [jdbc/OracleDB] is not bound in this Context. Unable to find [jdbc]}
- How do I get ASP.NET Web API to return JSON instead of XML using Chrome
- [LINUX LIVE USB]How to Make a bootable USB Drive to Install Fedora instead of using a physical DVD
- jdbc连接数据库使用sid和service_name的区别 oracle
- Java-httpClient警告: Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
- java中的使用JDBC出错:ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
- How-to find the SQL that using lots of temp tablespace in Oracle
- How to implement Quality Of Service using Floodlight
- How to run a Java Program as a daemon (service) on Linux (openSUSE) using a shell script
- How SID is different from Service name in Oracle tnsnames.ora
- SQL: How to get a series of dates in sql using connect by
- How to invoke Java web service in ASP.net using C#
- How to change the name of logfile dynamically using log4j
- How do I perform a manual full refresh instead of using the Apply program to do the full refresh?
- how-to: resolve "java.lang.OutOfMemoryError: Java heap space" during using beeline && hiveserver2
- 4000 jdbc连接Oracle使用SID与SERVICE NAME的方法
- How can JDBC connect to each type of databases?
- db_name,Oracle_sid, instance_name, service_name和sid的含义
- How to access other computer using different name/password
- How to add icon for the item of ListCtrl using C++ (Mail Attachment ListCtrl) - 如何用C++为ListCtrl的Item添加图标(邮件附件ListCtrl)