12c R1
11克R2
(注意:该驱动程序未包含在Maven Central中!)
Class.forName("oracle.jdbc.driver.OracleDriver");
较旧的格式,带有SID
"jdbc:oracle:thin:@<hostname>:<port>:<SID>"
较新的格式,带有服务名称
"jdbc:oracle:thin:@//<hostname>:<port>/<servicename>"
Tnsnames条目
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=<hostname>)(PORT=<port>))" +"(CONNECT_DATA=(SERVICE_NAME=<servicename>)))"
RAC群集连接字符串以进行故障转移
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)" +"(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname1>)(PORT=<port1>))" +"(ADDRESS=(PROTOCOL=TCP)(HOST=<hostname2>)(PORT=<port2>)))" +"(CONNECT_DATA=SERVICE_NAME=<servicename>)(SERVER=DEDICATED)))"
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "HR", "HRPASS");