當前位置: 首頁>>代碼示例>>Java>>正文


Java Driver.acceptsURL方法代碼示例

本文整理匯總了Java中java.sql.Driver.acceptsURL方法的典型用法代碼示例。如果您正苦於以下問題:Java Driver.acceptsURL方法的具體用法?Java Driver.acceptsURL怎麽用?Java Driver.acceptsURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.sql.Driver的用法示例。


在下文中一共展示了Driver.acceptsURL方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findDriver

import java.sql.Driver; //導入方法依賴的package包/類
private Driver findDriver(String realUrl) throws SQLException {

    Driver wrappedDriver = null;
    for (Driver driver : registeredDrivers()) {
      try {
        if (driver.acceptsURL(realUrl)) {
          wrappedDriver = driver;
          break;
        }
      } catch (SQLException e) {
        // intentionally ignore exception
      }
    }
    if (wrappedDriver == null) {
      throw new SQLException("Unable to find a driver that accepts " + realUrl);
    }
    return wrappedDriver;
  }
 
開發者ID:opentracing-contrib,項目名稱:java-jdbc,代碼行數:19,代碼來源:TracingDriver.java

示例2: getAllDriverInfos

import java.sql.Driver; //導入方法依賴的package包/類
public static DriverInfo[] getAllDriverInfos() {
    LinkedList predefinedDriverList = new LinkedList();
    Iterator driverList = getJDBCProperties().iterator();

    boolean accepted;
    DriverInfo predefinedInfo;
    while(driverList.hasNext()) {
        JDBCProperties drivers = (JDBCProperties)driverList.next();
        Enumeration driverArray = getAllDrivers();
        accepted = false;

        while(driverArray.hasMoreElements()) {
            Driver driver = (Driver)driverArray.nextElement();

            try {
                if(driver.acceptsURL(drivers.getUrlPrefix() + "localhost/test")) {
                    predefinedInfo = new DriverInfo(driver, drivers);
                    predefinedDriverList.add(predefinedInfo);
                    accepted = true;
                    break;
                }
            } catch (SQLException var7) {
                ;
            }
        }

        if(!accepted) {
            predefinedDriverList.add(new DriverInfo((Driver)null, drivers));
        }
    }

    LinkedList driverList1 = new LinkedList();
    Enumeration drivers1 = getAllDrivers();

    while(drivers1.hasMoreElements()) {
        Driver driverArray1 = (Driver)drivers1.nextElement();
        accepted = true;
        Iterator driver1 = predefinedDriverList.iterator();

        while(driver1.hasNext()) {
            predefinedInfo = (DriverInfo)driver1.next();
            if(predefinedInfo.getDriver() != null && predefinedInfo.getDriver().equals(driverArray1)) {
                accepted = false;
                break;
            }
        }

        if(accepted) {
            driverList1.add(new DriverInfo(driverArray1, (JDBCProperties)null));
        }
    }

    driverList1.addAll(predefinedDriverList);
    Collections.sort(driverList1);
    DriverInfo[] driverArray2 = new DriverInfo[driverList1.size()];
    driverList1.toArray(driverArray2);
    return driverArray2;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:59,代碼來源:DatabaseService.java


注:本文中的java.sql.Driver.acceptsURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。