Subject Re: [Firebird-Java] server vesion
Author Mark Rotteveel
On 3-2-2013 13:34, hugo.larson wrote:
> Hello,
> Is there a way to determine which version of Firebird is running before
> connection to a Database using pure JDBC?
> I'm looking in but cant find anything fitting.
> I'm currently using FB 1.5 and Jaybird 2.1.6.

There currently is no default way to get it in Jaybird (without actually
connecting to the database), but with the following code you can get the
server version without a reference to the database.

GDSType gdsType = FBTestProperties.getGdsType();
FBServiceManager fbServiceManager = new FBServiceManager(gdsType);

GDS gds = GDSFactory.getGDSForType(gdsType);
ServiceRequestBuffer srb =
IscSvcHandle svcHandle = fbServiceManager.attachServiceManager(gds);
byte[] buffer = new byte[1024];
gds.iscServiceQuery(svcHandle, null, srb, buffer);

// Now buffer[0] == ISCConstants.isc_info_svc_server_version
// server_version is a string, so get 2 byte length from position 1
int length = gds.iscVaxInteger(buffer, 1, 2);

// Get string from buffer position 3 for length
String serverVersion = new String(buffer, 3, length,


Output on my system is:
WI-V2.5.2.26539 Firebird 2.5

In Jaybird 2.2 you can then use the class
org.firebirdsql.gds.impl.GDSServerVersion to parse the version:

GDSServerVersion versionInfo =

This object gives you access to the various parts of the version (eg
major (=2), minor (=5), variant (=2), build (=26539)).

This code is Java 7 because of the use of
java.nio.charset.StandardCharsets class, for earlier Java versions you
need to use the character set name (string).

Note that I only use the FBServiceManager class to simplify attaching to
the servicemanager, you don't actually need it if you do all the
plumbing that the ServiceManager does here.

You will need to replace the FBTestProperties references with your own
information (for getting the GDSType, use GDSType.getType("PURE_JAVA")
(or "NATIVE" or "EMBEDDED").

Mark Rotteveel