5

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?

  • 1
    You can't get the version of the server without connecting to it. But you don't need Firebird specific classes to do so. You can use `Connection.getDatabaseMajorVersion()` and `Connection.getDatabaseMinorVersion()` –  Mar 17 '17 at 12:07
  • BTW, starting with FB 2.1 (or perhaps even 2.0) you don't need to use any API to fetch th server version after connection, one SQL SELECT does it. Without connection... I wonder... Perhaps Services API - those used to validate DB, backup-restore... They surely do exists, Delphi libraries can do it, but I don't now about Java – Arioch 'The Mar 17 '17 at 13:01
  • @a_horse_with_no_name - see the problem is about different connections! he want to connect to the server but not to any specific database within that server. And here is where the problems start! in FB2 and prior there was a single shared passwords database, so there was a notion of users on the server. No matter if you connected t osome DB or not under FB2- you had the same set of users/passwords available. It changed in FB3, now users belong to the databases not to the server. So when you connect to the server without database - where should it look for users and pwds? no DB - no users list – Arioch 'The Mar 17 '17 at 13:03
  • @Arioch'The Service API for users is also deprecated. – Mark Rotteveel Mar 17 '17 at 15:26

1 Answers1

2

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.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • FB Developer suggests using Windows user/password ( and to configure FB3 to allow it ) for such a task being possible. www.translate.ru -> http://www.sql.ru/forum/1253775/fb3-soedinenie-s-serverom-no-ne-s-bd – Arioch 'The Mar 17 '17 at 16:46
  • UPD. looks like abusing of SYSDBA... Depends on the environment, of course. Inside the house we use a simple internal tool, that connected as SYSDBA to a dedicated virtual db server. However then we do not even have the task to explore the network and find/detect all the fb servers. – Arioch 'The Mar 20 '17 at 07:55
  • @Arioch'The I fail to see how this addresses my answer. – Mark Rotteveel Mar 20 '17 at 07:57
  • If not SYSDBA - which user would u use to make this connection proceed? – Arioch 'The Mar 20 '17 at 10:12
  • @Arioch'The Any user will do to query the server version. – Mark Rotteveel Mar 20 '17 at 11:05
  • Any user? there easily may be NO user in FB3. If each Application DB would have a custom security database (for example would be a self-contained one), then there might be non server-wide security.fdb at all – Arioch 'The Mar 20 '17 at 15:32
  • @Arioch'The IIRC services API can't have a custom security database. – Mark Rotteveel Mar 21 '17 at 08:41
  • Dunno, I think DB-related services like validation and backup-restore are expected to have full support for the given database security, custom or not. But assuming you are right, that is exactly the point:there may be no security database for services at all - no server-global SecDB as FB3 no more needs it, and no DB-specific SecDB as you say services do not use it, thus no SecDB at all... That is a nice potential FB3-new gotcha – Arioch 'The Mar 21 '17 at 08:52