Before you can open a database connection, you must first register the Oracle JDBC drivers with your Java program. As mentioned earlier, the JDBC drivers enable your JDBC statements to access the database.
There are two ways to register the Oracle JDBC drivers: the first is to use the forName() method of the class java.lang.Class , and the second is to use the registerDriver() method of the JDBC DriverManager class. The following example illustrates the use of the forName() method:
Class.forName("oracle.jdbc.OracleDriver");
The second way to register the Oracle JDBC drivers is to use the registerDriver() method of the java.sql.DriverManager class, as shown in the following example:
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
Once you have registered the Oracle JDBC drivers, you can open a connection to a database.