我在Java Swing应用程序中使用JavaDB(Derby)作为嵌入式数据库。我想检测并打印我正在使用的JavaDB版本。我已将derby.jar
包含在我的.jar文件中以供应用程序使用。
如何检测和打印嵌入式JavaDB的版本?
答案 0 :(得分:3)
http://download.oracle.com/javadb/10.6.1.0/javadoc/jdbc3/org/apache/derby/tools/sysinfo.html
String version = sysinfo.getVersionString();
也可以从命令行运行:
java -jar yourjarfile.jar org.apache.derby.tools.sysinfo
如果您不想要编译时依赖项,您还可以从JDBC DatabaseMetaData获取版本信息:
conn.getMetaData().getDatabaseMajorVersion(); // and friends
答案 1 :(得分:0)
您也可以detect the product version directly using SQL:
select getdatabaseproductversion() from (values (1)) t (a);