Coding a JDBC Connection

You can establish a database connection in pure JDBC code.

To code a JDBC Connection:

  1. Import the JDBC classes using the statement

    import java.sql.*;

    This statement is required for all JDBC programming.
  2. Register the Oracle JDBC drivers with the Driver Manager using the statement

    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
  3. Get a connection to a data server using the statement calling one of the getConnection methods:

    Connection conn = DriverManager.getConnection(parameters...);

    There are three driver manager getConnection methods, differing in the number and types of their parameters.

For more information, see the Oracle Database JDBC Developer's Guide and Reference, available from the Oracle Database 10g Documentation Library on the Oracle Technology Network (OTN) at http://www.oracle.com/pls/db92/db92.homepage.


Embedding SQL in Java Programs with JDBC
Configuring Database Connections
Registering a New Third-Party JDBC Driver
Connection Requirements for Oracle's Type 2 JDBC Drivers (OCI)

 

Copyright © 1997, 2004, Oracle. All rights reserved.