Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Firebird server version info

I use java and jaybird driver. In my previous version with jaybird 2.x I used GDS low level access (Services API) to connect the server (without db-part in connection), to get the server version string.

Now I try to use FB3 + jaybird3beta. There are no GDS API in JB3. As I see from docs - there are org.firebirdsql.util.FirebirdSupportInfo object with 3 implementation

static FirebirdSupportInfo  supportInfoFor(Connection connection) 
static FirebirdSupportInfo  supportInfoFor(FbDatabase database) 
static FirebirdSupportInfo  supportInfoFor(GDSServerVersion serverVersion) 

As I see:

  • GDSServerVersion - Object representing a Firebird server version (already got somehow).
  • FbDatabase - Connection handle to a database.
  • Connection - some kind of "connection". So dig dipper:

there are also java.sql.DriverManager with getConnection() function that " Attempts to establish a connection to the given database URL"

So, as I understand it s unable to get server version without connection to any database? Or I miss something?

Or how can I get the version of server using only server:port and given username/password?

like image 678
Сергей Никитин Avatar asked Oct 29 '22 10:10

Сергей Никитин


1 Answers

Contrary to an earlier version of this answer, it is already possible (I had forgotten about it). To get the server version you can use the org.firebirdsql.management.FBServiceManager class:

FBServiceManager manager = new FBServiceManager();
manager.setHost("localhost");
manager.setUser("sysdba");
manager.setPassword("your password");
System.out.println(manager.getServerVersion());

This method is currently not exposed in the interface definition ServiceManager, I have created ticket JDBC-484 to address this for Jaybird 3.0.0 final.

As an aside: the class org.firebirdsql.util.FirebirdSupportInfo was primarily written to simplify testing in Jaybird itself for tests that depend on features introduced in different Firebird versions. We included it in the distribution package because it might be useful to others. Just keep in mind that the results of the feature check methods do not necessarily mean that such a feature is available to a specific database, as sometimes features also require a specific ODS (On-Disk Structure) version of the database file.

Disclosure: I am a developer of Jaybird.

like image 123
Mark Rotteveel Avatar answered Nov 15 '22 06:11

Mark Rotteveel