All of the answers here use the Class.forName("my.vandor.Driver");
line to load the driver.
As an (better) alternative you can use the DriverManager
helper class which provides you with a handful of methods to handle your JDBC driver/s.
You might want to
DriverManager.registerDriver(driverObject);
to register your driver to it's list of driversRegisters the given driver with the DriverManager. A newly-loaded driver class should call the method registerDriver to make itself known to the DriverManager. If the driver is currently registered, no action is taken
DriverManager.deregisterDriver(driverObject);
to remove it.Removes the specified driver from the DriverManager's list of registered drivers.
Example:
Driver driver = new oracle.jdbc.OracleDriver();
DriverManager.registerDriver(driver);
Connection conn = DriverManager.getConnection(url, user, password);
// ...
// and when you don't need anything else from the driver
DriverManager.deregisterDriver(driver);
or better yet, use a DataSource