views:

10

answers:

1

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?

+2  A: 

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
Thilo
Thanks. `conn.getMetaData().getDatabaseProductVersion();` provided the most specific information, `10.5.1.1 - (764942)`.
Jonas