Since Java 6, the recommended way to access an SQL-based database in Java is via the JDBC(Java DataBase Connectivity) API.
This API comes in two packagages:
JDBC defines database interactions in terms of
Driver interacts with the database, and provides a simplified interface for opening and managing connections. Most database server varieties (PostgreSQL, MySQl, etc.) have their own
Drivers, which handle setup, teardown, and translation specific to that server.
Drivers are usually not accessed directly; rather, the interface provided by the
DriverManager object is used instead.
DriverManager object is essentially the core of JDBC. It provides a (mostly) database-agnostic interface to create
Connections. For older versions of the JDBC API, database-specific
Drivers had to be loaded before
DeviceManager could create a connection to that database type.
Connection is, as the name implies, a representation of an open connection to the database.
Connections are database-agnostic, and are created and provided by the
DriverManager. They provide a number of 'shortcut' methods for common query types, as well as a raw SQL interface.