Search code examples
jarversionjavadbderby

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?


Solution

  • 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