【发布时间】:2015-12-10 17:29:15
【问题描述】:
编辑:
我正在测试我在另一篇文章中找到的代码以查找数据库名称:
public static String getDBname(Connection conn) {
String result = null;
int i = 0;
try {
ResultSet rs = conn.getMetaData().getCatalogs();
while (rs.next()) {
System.out.println(rs.getString(i));
i ++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
但是它只是返回了这个错误:
net.ucanaccess.jdbc.FeatureNotSupportedException: Feature not supported.
at net.ucanaccess.jdbc.UcanaccessDatabaseMetadata.getCatalogs(UcanaccessDatabaseMetadata.java:310)
还有其他方法可以做到这一点吗?
【问题讨论】:
-
"Feature not supported" 对我来说似乎很清楚。
-
顺便说一句:要获得“当前选定的数据库”,您需要调用
getCatalog()而不是getCatalogs() -
@a_horse_with_no_name 我确实尝试使用
conn.getCatalog(),但它只是返回了“PUBLIC”,这不是我的数据库名称。
标签: java jdbc ucanaccess