JDBC Drivers

A JDBC driver is the piece of software that sits between your Java code and the actual database. Your program only ever calls standard JDBC interfaces like Connection and Statement — it has no idea how MySQL, PostgreSQL, or Oracle actually talk over the network. The driver's job is to translate those standard JDBC calls into whatever network protocol the specific database understands, and translate the responses back into JDBC objects your code can use.

Think of it as an adapter: your code speaks "JDBC", the database speaks its own protocol, and the driver converts between the two — so switching databases mostly means swapping the driver and the connection URL, not rewriting your queries.

The Four Driver Types

When JDBC was first designed, Sun defined four categories of drivers based on how much native (non-Java) code they relied on. Only one of these categories is actually used today, but the classification still shows up in textbooks and interview questions, so it's worth knowing.

TypeNameHow it works today
Type 1JDBC-ODBC BridgeRouted JDBC calls through an ODBC driver. Obsolete — removed from the JDK since Java 8 and never used in modern projects.
Type 2Native-API DriverPart Java, part native (C/C++) client library specific to the database. Rare today; requires platform-specific binaries.
Type 3Network Protocol DriverPure Java, but talks to a middleware server that translates to the database's protocol. Rare; adds an extra hop.
Type 4Thin DriverPure Java, talks directly to the database over the network using its native protocol. No middleware, no native binaries.
In practice: virtually every JDBC driver you'll use in a real project today — for MySQL, PostgreSQL, Oracle, SQL Server, or anything else — is a Type 4 thin driver. Types 1-3 are historical context, not something you'll configure yourself.

Real Type 4 Drivers You'll Actually Use

DatabaseDriverDriver class name
MySQLMySQL Connector/Jcom.mysql.cj.jdbc.Driver
PostgreSQLPostgreSQL JDBC Driver (pgJDBC)org.postgresql.Driver
Oracleojdbc (Oracle JDBC Driver)oracle.jdbc.driver.OracleDriver

Where the Driver Class Name Comes From

Every driver ships a class that implements java.sql.Driver. Historically you loaded it explicitly with Class.forName(...) so the JVM would register it with DriverManager. The example below shows the fully-qualified class name for the modern MySQL Connector/J driver:

Example: The MySQL Type 4 Driver Class Name

public class DriverNameExample {
  public static void main(String[] args) throws Exception {
    // Fully-qualified class name of the MySQL Connector/J Type 4 driver
    Class.forName("com.mysql.cj.jdbc.Driver");
  }
}
Next up: Head to Project Setup to see how you actually get one of these drivers into your project — manually, or with a build tool.