4

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?

Jonas
  • 121,568
  • 97
  • 310
  • 388

2 Answers2

3

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
  • 257,207
  • 101
  • 511
  • 656
  • 4
    Thanks. `conn.getMetaData().getDatabaseProductVersion();` provided the most specific information, `10.5.1.1 - (764942)`. – Jonas Oct 20 '10 at 09:05
  • Is there a SQL query that can return similar info? Something like SELECT @@VERSION (SQL Server) and SELECT VERSION() (MySQL)? – enigment Aug 04 '16 at 14:05
0

You can also detect the product version directly using SQL:

select getdatabaseproductversion() from (values (1)) t (a);
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509