本文整理汇总了Java中java.sql.DatabaseMetaData.getDriverVersion方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMetaData.getDriverVersion方法的具体用法?Java DatabaseMetaData.getDriverVersion怎么用?Java DatabaseMetaData.getDriverVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.DatabaseMetaData
的用法示例。
在下文中一共展示了DatabaseMetaData.getDriverVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecycleBinObjects
import java.sql.DatabaseMetaData; //导入方法依赖的package包/类
private Set<String> getRecycleBinObjects(DatabaseMetaData dmd, String... types) {
String driverName = null;
String driverVer = null;
List<String> emptyList = Collections.emptyList();
Set<String> result = new HashSet<String>();
try {
driverName = dmd.getDriverName();
driverVer = dmd.getDriverVersion();
int databaseMajorVersion = 0;
try {
databaseMajorVersion = dmd.getDatabaseMajorVersion();
} catch (UnsupportedOperationException use) {
LOGGER.log(Level.FINEST, "getDatabaseMajorVersion() on " + dmd, use);
}
if (databaseMajorVersion < 10 || types == null) {
return Collections.emptySet();
}
Statement stmt = dmd.getConnection().createStatement();
ResultSet rs = null;
try {
rs = stmt.executeQuery("SELECT OBJECT_NAME, TYPE FROM SYS.DBA_RECYCLEBIN"); // NOI18N
} catch (SQLException ex) {
LOGGER.log(Level.FINE, ex.getMessage(), ex);
// try both
rs = stmt.executeQuery("SELECT OBJECT_NAME, TYPE FROM RECYCLEBIN"); // NOI18N
}
if (rs != null) {
List<String> typesL = types == null ? emptyList : Arrays.asList(types);
try {
while (rs.next()) {
String type = rs.getString("TYPE"); // NOI18N
if (typesL.isEmpty() || typesL.contains(type)) {
result.add(rs.getString("OBJECT_NAME")); // NOI18N
}
}
} finally {
rs.close();
}
}
stmt.close();
} catch (Exception e) {
LOGGER.log(Level.INFO, "Error while analyzing the recycle bin. JDBC Driver: " + driverName + "(" + driverVer + ")", e);
}
return result;
}