Java JDBC Driver getUnderlyingDriver(String url)

Here you can find the source of getUnderlyingDriver(String url)

Description

Given a jdbc:ssh type URL, find the underlying real driver that accepts the URL.

License

Apache License

Parameter

Parameter Description
url JDBC connection URL.

Exception

Parameter Description
SQLException if a database access error occurs.

Return

Underlying driver for the given URL. Null is returned if the URL is not a jdbc:ssh type URL or there is no underlying driver that accepts the URL.

Declaration

private static Driver getUnderlyingDriver(String url) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.Driver;
import java.sql.DriverManager;

import java.sql.SQLException;
import java.util.Enumeration;

public class Main {
    /**/*from w  ww.j av a  2 s .c  o  m*/
     * Given a <code>jdbc:ssh</code> type URL, find the underlying real driver
     * that accepts the URL.
     * 
     * @param url
     *            JDBC connection URL.
     * 
     * @return Underlying driver for the given URL. Null is returned if the URL
     *         is not a <code>jdbc:ssh</code> type URL or there is no underlying
     *         driver that accepts the URL.
     * 
     * @throws SQLException
     *             if a database access error occurs.
     */
    private static Driver getUnderlyingDriver(String url) throws SQLException {

        Enumeration e = DriverManager.getDrivers();

        Driver d;
        while (e.hasMoreElements()) {
            d = (Driver) e.nextElement();

            if (d.acceptsURL(url)) {
                return d;
            }
        }
        return null;
    }
}

Related

  1. getDriverClassName(String rawUrl)
  2. getDriverFromPath(String path, String className)
  3. getRegisteredDrivers()
  4. getRSInfo(Object rsObj, int[] rsInfo, long[] rsCounter, Object[] conn, int[] errCode, String[] errDetail)
  5. getStatement()
  6. hasDriver()
  7. isDriverLoaded(String driver)
  8. loadDriver(String driver)
  9. loadDriver(String driverClassName, String jarFileName)