JDBC Fundamentals
Connections, statements, result sets.
What is JDBC?
JDBC (Java Database Connectivity) is the standard API for talking to relational databases from Java.
- It lives in the
java.sqlpackage. - Each database ships a driver that implements the JDBC interfaces.
- You write code against interfaces like
Connection,Statement, andResultSet— never against the vendor classes directly.
This abstraction lets the same code work against PostgreSQL, MySQL, H2, or Oracle.
The Core Interfaces
Three interfaces do most of the work:
Connection— an open session with the database.Statement/PreparedStatement— sends SQL.ResultSet— a cursor over the rows returned by a query.
You obtain a Connection from DriverManager or a DataSource.
All lessons in this course
- JDBC Fundamentals
- PreparedStatement
- Transactions
- Connection Pooling with HikariCP