本文整理匯總了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;
}
示例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;
}