List of utility methods to do JDBC Driver
Driver | getUnderlyingDriver(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; |
void | hasDriver() has Driver try { Class.forName("com.mysql.jdbc.Driver"); } catch (ClassNotFoundException ex) { throw new SQLException("Invalid Driver!!Please check this driver...."); |
boolean | isDriverLoaded(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; ... |
Class | loadDriver(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()); ... |
Driver | loadDriver(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 { ... |
void | printAllDrivers() print All Drivers for (Enumeration e = DriverManager.getDrivers(); e.hasMoreElements();) { System.err.println("2 DRIVER FOUND == " + e.nextElement()); |