O'Reilly logo

Special Edition Using Java 2 Standard Edition by Geoff Friesen, Chuck Cavaness, Brian Keeton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required