(Note: the driver is not included in Maven Central!)
Class.forName("oracle.jdbc.driver.OracleDriver");
Older format, with SID
"jdbc:oracle:thin:@<hostname>:<port>:<SID>"
Newer format, with Service Name
"jdbc:oracle:thin:@//<hostname>:<port>/<servicename>"
Tnsnames like entry
"jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=<hostname>)(PORT=<port>))"
+"(CONNECT_DATA=(SERVICE_NAME=<servicename>)))"
RAC cluster connection string for failover
"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");