Jaybird and Firebird 3
Clone this wiki locally
Firebird 3.0 was just released, see "Firebird 3.0 is released". This article describes how to use Firebird 3.0 with Jaybird 2.2.x and earlier.
Firebird 3 introduces a new authentication mechanism, combined with wire protocol encryption. This new authentication mechanism (SRP) is not supported by Jaybird 2.2.x and earlier when you use the pure java wire protocol (the default).
SRP will be supported in Jaybird 3.0, we plan to provide support for wire encryption in Jaybird 3.1, or maybe in Jaybird 3.0.
Jaybird 2.2 does not support the new wire encryption, to get Jaybird to work with Firebird 2.2, it is necessary to change the
WireCrypt setting from its default
Disabled, but that is not advisable as that will also disable it for clients that do support wire encryption.
WireCrypt = Enabled
Pure Java authentication
For the pure java wire protocol to authenticate to Firebird 3 you need to enable legacy authentication and correctly setup your users.
Setting up legacy authentication for Firebird 3 requires modifying the
firebird.conf by adding (or modifying) the line with
AuthServer = :
AuthServer = Srp, Win_Sspi, Legacy_Auth
Restart the Firebird service after you have saved the file.
Srp is the default new authentication,
Win_Sspi is for the trusted Windows authentication, and
Legacy_Auth enables the legacy authentication mechanism of Firebird 2.5 and earlier.
Using SQL user management
By default users created through SQL user management, the services API,
gsec or another way will be setup for
Srp. These users don't exist for the legacy authentication and trying to authenticate will result in the Exception:
org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544472. Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
To setup a user for the legacy authentication, you need to change the
UserManager in the
UserManager = Srp, Legacy_UserManager
The default value is
UserManager = Srp. Restart Firebird server after changing this. Next you need to create the user, for example to create a user
jaybird with password
jdbc. This can be done using the new SQL based user management (eg through ISQL or Flamerobin with the sysdba account):
CREATE USER jaybird PASSWORD 'jdbc' USING PLUGIN Legacy_UserManager
Using deprecated gsec or service manager
If you want to use the - deprecated(!) - gsec or servicemanager, you need to change the
UserManager in the
UserManager = Legacy_UserManager
You don’t need to restart the Firebird service after changing this if you are going to use
gsec (TODO: Also for services API?).
To create the user, for example user
jaybird with password
> gsec -user sysdba -password masterkey GSEC> add jaybird -pw jdbc
After doing this you should be able to connect to Firebird 3 with Jaybird 2.2.8. I'd suggest to revert the
UserManager setting in
firebird.conf to its default after you have set up the users.
Type 2 (native) authentication
(TODO: Test if
jdbc:firebirdsql:native does work)
Firebird 3 introduces a few new datatypes.
Firebird 3 adds the
BOOLEAN datatype (sqltype 32764/32765). This datatype is supported by Jaybird 2.2.4 and later.
In Jaybird 2.2.3 and earlier, using boolean values (in select, insert, etc) of this types will yield the following exception:
Exception in thread "main" org.firebirdsql.jdbc.field.TypeConversionException: SQL type for this field is not yet supported. at org.firebirdsql.jdbc.field.FBField.createException(FBField.java:186) at org.firebirdsql.jdbc.field.FBField.createField(FBField.java:468) at org.firebirdsql.jdbc.field.FBField.createField(FBField.java:379) at org.firebirdsql.jdbc.AbstractResultSet.prepareVars(AbstractResultSet.java:200) at org.firebirdsql.jdbc.AbstractResultSet.<init>(AbstractResultSet.java:144) at org.firebirdsql.jdbc.FBResultSet.<init>(FBResultSet.java:46) at org.firebirdsql.jdbc.AbstractStatement.getResultSet(AbstractStatement.java:913) at org.firebirdsql.jdbc.AbstractStatement.getResultSet(AbstractStatement.java:894) at org.firebirdsql.jdbc.AbstractStatement.executeQuery(AbstractStatement.java:225)
A workaround is to wrap the field in an
SELECT IIF(boolvalue, 1, 0) AS boolvalue FROM booltable
Or for insert, use an expression with a boolean result in the value list:
INSERT INTO booltable(id, boolvalue) VALUES (?, 1 = ?)
This works because the second parameter will be identified as an integer, and when you use
setBoolean() on the
PreparedStatement, it will use
Firebird 3.0 introduces an autoincrement field (
<datatype> GENERATED BY DEFAULT AS IDENTITY). Jaybird 2.2.x does not have identity support, in other words it will be handled like any other
<datatype> NOT NULL field. For example in
DatabaseMetaData.getColumns() will not report
YES for the column
IS_AUTOINCREMENT (instead it reports empty string, meaning "it cannot be determined whether the column is auto incremented").
Other operations, including retrieving generated keys, will work for this column, just as it works for normal columns.
There currently are no issues. If you come across any problems with using Jaybird on Firebird 3, please report them on Firebird-Java or in the Firebird JDBC tracker.