JDBC  «Prev  Next»
Lesson 8

JDBC Database Management Conclusion

Connect to databases using JDBC.

This module gave you the skills and knowledge to enable you to connect to a DBMS using JDBC.
Specifically, you have learned to:
  1. Describe the different pieces of the JDBC specification
  2. Write JDBC URLs
  3. Define the three functions that JDBC drivers perform in the data request process
  4. Define the purpose of four basic JDBC drivers
  5. Use the JDBC DriverManager to connect to the DBMS
  6. Write a simple yet complete JDBC program
In the next module, you will create and populate a database table.


JDBC Programming

JDBC programming can be explained in the following simple steps:
  1. Importing required packages
  2. Registering the JDBC drivers
  3. Opening a connection to a database
  4. Creating a Statement/PreparedStatement/CallableStatement object
  5. Executing a SQL query and returning a ResultSet object
  6. Processing the ResultSet object
  7. Closing the ResultSet and Statement objects
  8. Closing the connection

The first hands-on experience with JDBC in this module involves a basic and complete example to illustrate the overall concepts related to creating and accessing data in a database. Here, we assume that a database (MySQL or Oracle) is created and available for use. Database creation is DBMS-specific.
This means that each vendor has a specific set of commands for creating a database. For this obvious reason, database creation commands are not portable (this is the main reason why JDBC has stayed away from database creation commands).
Step 1: Import the Required Packages
Before you can use the JDBC driver to get and use a database connection, you must import the following packages: java.sql and javax.sql.
import java.sql.*;
import javax.sql.*;
To import classes and interfaces properly, refer to the Java Language Specification