Oracle JDBC Driver and URL Information


Listed below are database connection examples for three common JDBC drivers for Oracle:

Oracle Thin JDBC Driver


In order to use the Oracle thin driver, the jar or zip file containing the Oracle thin driver must be obtained. Oracle provides this download free of charge, but may require you to register on the Oracle site to proceed with the download. The Oracle thin Driver is also usually included in the Oracle client installation. If you have the Oracle client installation on your machine, the location of the thin drivers should be in the classes12.zip file or the ojdbc14.jar file for newer Oracle versions. Consult the documentation from Oracle for details.

DRIVER CLASS: oracle.jdbc.driver.OracleDriver

DRIVER LOCATION: Simply specify the location of the jar or zip file that contains the Oracle Thin drivers.

JDBC URL FORMAT:
jdbc:oracle:thin:@//<host>:<port>/ServiceName
or
jdbc:oracle:thin:@<host>:<port>:<SID>

NOTE: The Oracle thin driver requires the SID or ServiceName of the database in the JDBC URL as opposed to the database alias. Consult your Oracle documentation for more details.

JDBC URL Examples:

jdbc:oracle:thin:@//localhost:1521/XE
jdbc:oracle:thin:@neptune.acme.com:1521:T10A

jdbc:oracle:thin:@127.0.0.1:1521:T10A


Oracle OCI JDBC Driver


DRIVER CLASS: oracle.jdbc.driver.OracleDriver

DRIVER LOCATION: In order to use the Oracle OCI drivers, a Oracle client installation is usually required on your machine. If using the OCI drivers, you must supply the jar or zip file located in the Oracle client directory path to connect to the database. The OCI drivers are usually contained in the classes12.zip file or the ojdbc14.jar file for new Oracle versions.

JDBC URL FORMAT: jdbc:oracle:oci:@<database_string>

The database string can either be simply a TNSName, or a combination of host, port, and sid / service name.

For example:

host_or_ip_address:port:sid

host_or_ip_address:port/service

JDBC URL Examples:

jdbc:oracle:oci:@TEST

jdbc:oracle:oci:@192.168.1.1:1521/XE


Oracle 8i OCI JDBC Driver


DRIVER CLASS: oracle.jdbc.driver.OracleDriver

DRIVER LOCATION: In order to use the Oracle OCI drivers, a Oracle client installation is usually required on your machine. If using the OCI drivers, you must supply the jar or zip file located in the Oracle client directory path to connect to the database. The OCI drivers are usually contained in the classes12.zip file.

JDBC URL FORMAT: jdbc:oracle:oci8:@<database_string>

JDBC URL Examples:

jdbc:oracle:oci8:@TEST