Java Utililty Methods JDBC Driver

List of utility methods to do JDBC Driver

Description

The list of methods to do JDBC Driver are organized into topic(s).

Method

DrivergetUnderlyingDriver(String url)
Given a jdbc:ssh type URL, find the underlying real driver that accepts the URL.
Enumeration e = DriverManager.getDrivers();
Driver d;
while (e.hasMoreElements()) {
    d = (Driver) e.nextElement();
    if (d.acceptsURL(url)) {
        return d;
return null;
voidhasDriver()
has Driver
try {
    Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
    throw new SQLException("Invalid Driver!!Please check this driver....");
booleanisDriverLoaded(String driver)
Check if the database driver is loaded.
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
    Driver d = drivers.nextElement();
    if (d.getClass().getName().equals(driver)) {
        return true;
return false;
...
ClassloadDriver(String driver)
load the driver, if 'driver' is null then uses DEFAULT_DRIVER
try {
    if (driver == null)
        driver = DEFAULT_DRIVER;
    System.out.println("........loading:" + driver);
    Class drCl = Class.forName(driver);
    return drCl;
} catch (IllegalArgumentException iae) {
    throw new SQLException("Driver class (" + driver + "): possibly wrong format: " + iae.getMessage());
...
DriverloadDriver(String driverClassName, String jarFileName)
load Driver
Class<Driver> driverClazz;
if (jarFileName != null) {
    File driverFile = new File(jarFileName);
    if (!driverFile.exists()) {
        throw new FileNotFoundException("File: " + jarFileName + " NOT FOUND");
    URL url;
    try {
...
voidprintAllDrivers()
print All Drivers
for (Enumeration e = DriverManager.getDrivers(); e.hasMoreElements();) {
    System.err.println("2 DRIVER FOUND == " + e.nextElement());