Download | Release Notes |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
Oracle Database 19c and 18c JDBC drivers introduce a new property file (ojdbc.properties) along with few other features that simplifies the connection to Autonomous Transaction Processing (ATP) and Autonomous Data Warehousing (ADW). The Oracle JDBC driver class that implements the java.sql.Driver interface. Register the JDBC drivers To access a database from a Java application, you must first provide the code to register your installed driver with your program. You do this with the static registerDriver method of the java.sql.DriverManager class. The JDBC-ODBC bridge driver uses ODBC driver to connect to the database. The JDBC-ODBC bridge driver converts JDBC method calls into the ODBC function calls. This is now discouraged because of thin driver.
A JDBC example to show you how to connect to a Oracle database with a JDBC driver.
Tested with:
- Java 8
- Oracle database 19c
- Oracle JDBC driver for Java 8,
ojdbc8.jar
1. Download Oracle JDBC Driver
Visit Oracle database website and download the Oracle JDBC Driver.
2. JDBC Connection
Find your Oracle SID in
{ORACLE_HOME}/network/admin/tnsnames.ora
to avoid the popular ORA-12505, TNS:listener does not currently know of SID2.1 Make a connection to the Oracle database.
Compile and run:
2.2 Assume ojdbc8.jar
and JDBCExample.java
are stored in c:test
together. Define a -cp
option to load everything together:
3. Maven Project
3.1 Sorry, due to Oracle license restriction, the Oracle JDBC driver is NOT available in the Maven central repository. Follow this guide to add it – How to add Oracle JDBC driver in your Maven local repository
3.2 Alternatively, defined a system scope to find the .jar
file with a specified system path.