JDBC connection to Oracle database (transfer)

 

Java program to access Oracle database cluster and non-cluster different connection strings


1. The url url=jdbc:oracle:thin:@host_ip:1521:dbname of the java program connection in the Oracle non-cluster

2.oracle集群中java程序连接的url
url=jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =db1)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST =db2)(PORT = 1521))(LOAD_BALANCE=yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = dbname)))

 

----------------------------------------------------------------------------------------

The DBC application encountered a problem connecting to Oracle, the error is as follows:

 

ORA-12505,TNS:listener does not currently know of SID given in connect descriptor TheConnection descriptor used by the client was。

 

I configured static registration at the DB level, and GLOBAL_DBNAME and SID_NAME are different, the previous configuration is the same, so I did not find this problem.

 

 

 

   (SID_DESC =

 

     (GLOBAL_DBNAME = dave)

 

         (ORACLE_HOME =D:\app\Administrator\product\11.2.0\dbhome_1)

 

     (SID_NAME = NEWCCS)

 

    )

 

 

Oracle Listener dynamic registration and static registration

 

http://blog.csdn.net/tianlesoftware/article/details/5543166

 

The formats of the JDBC Thin Driver have three formats:

 

格式一:  Oracle JDBC Thin using a ServiceName: 

 

jdbc:oracle:thin:@//<host>:<port>/<service_name> 
Example: jdbc:oracle:thin:@//192.168.2.1:1521/XE

 

 

Note the format here, there is // after @, which is the main difference from using SID.

 

This format is recommended by Oracle because the SID of each node is different for the cluster, but SERVICE_NAME can indeed contain all nodes.

 

 

 

Format 2:  Oracle JDBC Thin using an SID: 

jdbc:oracle:thin:@<host>:<port>:<SID> 
Example: jdbc:oracle:thin:192.168.2.1:1521:X01A 

Note: Support for SID is being phased out. Oracle recommends that users switch over to usingservice names.

 

Format 3: Oracle JDBC Thin using a TNSName: 

 

jdbc:oracle:thin:@<TNSName> 
Example: jdbc:oracle:thin:@GL 

Note: 
Support for TNSNames was added in the driver release 10.2.0.1

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327068868&siteId=291194637