Creating a Database Connection

You need a database connection to talk to a database system. There are two key elements in a database connection:

  • java.sql.DriverManager

  • A JDBC Driver

It is the responsibility of the DriverManager class to maintain a list of instances of JDBC drivers available to a given JVM at runtime. Essentially, this list provides information about the object reference of a driver and the subprotocol, or database type, that it supports. When a program requests a database connection, the DriverManager goes through the list, asking each driver if it can process the getConnection() request. The search is based on the database URL supplied in the getConnection() call, which is discussed later in this chapter. The DriverManager tells ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.