Nearby lessons
6 of 37JDBC - The JDBC API
📌 What You Will Learn
- The full JDBC architecture and how the parts connect
- DriverManager — the manager of all drivers
- Database Driver — the bridge
- The two JDBC packages: java.sql and javax.sql
- The important classes and interfaces of JDBC
The JDBC API is a fundamental part of database programming with JDBC. This lesson explains JDBC API — The Two Packages and The JDBC API at a Glance — Memory Map with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
JDBC API — The Two Packages
The JDBC API defines two packages:
1) java.sql — the basic package
Contains the core classes and interfaces for database communication. The most important ones:
| Interfaces | Classes |
|---|---|
| Driver | DriverManager |
| Connection | Date, Time, Timestamp |
| Statement | DriverPropertyInfo |
| PreparedStatement | Types |
| CallableStatement | SQLException |
| ResultSet | SQLWarning |
| ResultSetMetaData | Savepoint |
| DatabaseMetaData | |
| Blob, Clob |
2) javax.sql — the extended package
Contains advanced features used mostly in enterprise applications:
| Interface / class | Purpose |
|---|---|
| DataSource | The modern way to get connections (replaces DriverManager) |
| ConnectionPoolDataSource | For connection pooling |
| RowSet | A more flexible ResultSet |
| XADataSource | For distributed (XA) transactions |
Trainer's Note: Updated knowledge: in real applications today, we prefer DataSource (via connection pools like HikariCP) over DriverManager.getConnection(). But DriverManager is perfect for learning — every concept carries over.
The JDBC API at a Glance — Memory Map
Example02
📝 Key Takeaways
- Architecture: Java app → JDBC API → DriverManager → Driver → Database.
- DriverManager registers drivers and creates connections.
- Driver is the bridge that converts Java calls to database calls and back.
- JDBC API = java.sql (basic) + javax.sql (advanced/enterprise).
- Key interfaces: Driver, Connection, Statement, PreparedStatement, CallableStatement, ResultSet.
- Modern apps use DataSource + connection pools instead of DriverManager.
🧠 Test Your Knowledge
4 QuestionsProgress: 0 / 4