Regardless of which Oracle JDBC driver you use, include the following import statements at the beginning of your program (java.math only if needed):
import java.sql.*; for standard JDBC packages
import java.math.*; for BigDecimal and BigInteger classes
Import the following Oracle packages when you want to access the extended functionality provided by the Oracle drivers. However, they are not required for the example presented in this section:
import oracle.sql.*; for Oracle extensions to JDBC
Register the JDBC Drivers
You must provide the code to register your installed driver with your program. You do this with the static registerDriver() method of the JDBC DriverManager class. This class provides a basic service for managing a set of JDBC drivers.
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
Open a Connection to a Database
Open a connection to the database with the static getConnection() method of the JDBC DriverManager class.
If you want to connect with the Thin driver, you must specify the port number and SID. For example, if you want to connect to the database on host myhost that has a TCP/IP listener up on port 1521, and the SID (system identifier) is orcl: