Connecting to the Database

Connecting to a database using JDBC can be divided into two steps. The first involves loading the JDBC driver and the second step is actually making the connection. Each step is described individually in the following sections.

Loading the Driver

A JDBC driver is loaded using the Class.forName method. The single argument to the method is the name of the driver that you want to load. This may seem a little confusing at first.You need to figure out what the driver class name is from the driver documentation and thencall the forName method. The forName("className") method initializes and loads an instance of the named class and returns the Class object for the class specified by the argument to the forName method.

Caution ...

Get Special Edition Using Java 2 Standard Edition 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.