The
JDBC API is designed to run with any complient driver. When you ask JDBC for a connection to a database, the DriverManager needs to know which driver to get it from. It gets this information from the 'jdbc.driver' property stored in the
Java System properties. (ie
NOT the actual computer properties.)
There are (generally) two ways of defining a driver. The easiest is to call Class.forName("fully qualified driver name"). This makes it the driver's responsibility to register itself with JDBC and life goes on.
The other way is to define the driver name on the command line when executing the program using the
-D<name>=<value> option.
(The code above provided by Thomas is equivalent to the first method)
A third method that I hadn't thought of is to simply write the driver name directly to the JVM properties, although I don't see any advantage over the Class.forName() method...
DOM