Core JDBC Interfaces
Fast recall
Quick revision
Core answer
Whether you can name the key JDBC interfaces and their responsibilities.
Confusing the Statement subtypes or thinking they're concrete classes.
Note these are interfaces implemented by the vendor driver — the source of JDBC portability.
Interview-ready guide
Interview answer
A typical application asks a DataSource for Connection, prepares SQL, binds values, executes, reads ResultSet, and closes each resource. SQLException is the checked exception family used for failures, but it is a class rather than an interface. Distinguishing contracts from utility classes prevents the inaccurate list 'DataSource, DriverManager, and Driver are all core interfaces'.
Core JDBC Interfaces
Direct Answer
The main JDBC interfaces include Driver, Connection, Statement, PreparedStatement, CallableStatement, ResultSet, and DatabaseMetaData. DataSource is a javax.sql interface used to obtain connections. DriverManager is an important utility class, not an interface. JDBC code targets these contracts while a driver supplies most concrete implementations.
Code Example
DataSource ds = ...; // DataSource
try (Connection con = ds.getConnection(); // Connection
PreparedStatement ps = // PreparedStatement
con.prepareStatement("SELECT name FROM users WHERE id = ?")) {
ps.setLong(1, 7L);
try (ResultSet rs = ps.executeQuery()) { // ResultSet
if (rs.next()) System.out.println(rs.getString("name"));
}
}
// Every type above is an interface; the JDBC driver supplies the classes.
Common Mistakes & Pitfalls
- Treating them as classes: they're interfaces implemented by the driver.
- Confusing the Statement subtypes: Statement (static), PreparedStatement (params), CallableStatement (procedures).
- Forgetting
DataSource: it's the modern entry point, notDriverManager. - Assuming ResultSet is scrollable: it's forward-only by default.
Check your understanding
Answer these without looking back at the article.
- What is JDBC and why does it exist? It provides a standard Java API for connecting to relational databases, executing SQL, and processing results without vendor-specific code.
- What is JDBC and what is its role in Java?
- What are the main components of the JDBC API?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.