本文整理汇总了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;
}