How can I detect what version of JavaDB/Derby I'm using?
I use JavaDB (Derby) as an embedded database in my Java Swing application. I would like to detect and开发者_运维问答 print the version of JavaDB I'm using. I have included derby.jar
in my .jar-file for the application.
How can I detect and print the version of my embedded JavaDB?
http://download.oracle.com/javadb/10.6.1.0/javadoc/jdbc3/org/apache/derby/tools/sysinfo.html
String version = sysinfo.getVersionString();
Can also be run from the command line:
java -jar yourjarfile.jar org.apache.derby.tools.sysinfo
If you do not want the compile-time dependency, you can also get the version info from the JDBC DatabaseMetaData:
conn.getMetaData().getDatabaseMajorVersion(); // and friends
You can also detect the product version directly using SQL:
select getdatabaseproductversion() from (values (1)) t (a);
精彩评论