JDBC connection database uses different writing methods of SERVICE NAME, SID and TNSName

This week, when using jdbc to connect to the customer's oracle, there is always a timeout.
Always use the SID to connect to the database. After trying to change to Service Name, the connection is successful.

There are three ways for the Java JDBC Thin Driver to connect to Oracle.

Format 1: Use ServiceName method:
jdbc:oracle:thin:@//<host>:<port>/<service_name> Example jdbc:oracle:thin: @
//xxx.xxx.xxx.xxx:1526/CDEV@
There is //, which is the main difference from using SID. (11g does not add // after @)
This format is recommended by Oracle.
Because for the cluster, the SID of each node is different, and the SERVICE NAME can contain all nodes.

Format 2: Use SID method:
jdbc:oracle:thin:@<host>:<port>:<SID>
Example jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1526:CDEV2

Format 3: Use TNSName method :
jdbc:oracle:thin:@<TNSName>
Example jdbc:oracle:thin:@CDEV
Note that ORACLE supports TNSNames since 10.2.0.1

Guess you like

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