Subject Re: [Firebird-Java] Default Dialect on Connection
Author Roman Rokytskyy
Hi,

> Recently I was made aware that I have to specify which Dialect to use
> when connecting to a database, otherwise it will default to 3. We are
> currently using Dialect 1 database (just converted from IB 5.6). My
> developers are asking whether or not this default is a Jaybird specific
> thing or if Firebird is defaulting. If it is a Jaybird thing can you
> point out where it is setting this in the source code?

This is general contract of the API at least in IB 6.0 - we have to pass
dialect when preparing the SQL statement (see IB 6.0 API Guide):

isc_dsql_prepare(): Prepares a DSQL statement for repeated execution.

Syntax :

ISC_STATUS isc_dsql_prepare(
ISC_STATUS *status_vector,
isc_tr_handle *trans_handle,
isc_stmt_handle *stmt_handle,
unsigned short length,
char *statement,
unsigned short dialect,
XSQLDA *xsqlda);

....

dialect - unsigned short
• Indicates the SQL dialect of statement
• Must be less than or equal to the SQL dialect of the client

and there are following constants in the ibase.h:

#define SQL_DIALECT_V5 1
#define SQL_DIALECT_V6_TRANSITION 2
#define SQL_DIALECT_V6 3
#define SQL_DIALECT_CURRENT SQL_DIALECT_V6

And that's exactly what Jaybird does as well. The SQL_DIALECT_CURRENT
constant is defined in the ISCConstants class (on the very beginning of
the file) and is used in the GDSHelper.prepareStatement(...) method:

int dialect = ISCConstants.SQL_DIALECT_CURRENT;
if (dpb.hasArgument(ISCConstants.isc_dpb_sql_dialect))
dialect = dpb.getArgumentAsInt(ISCConstants.isc_dpb_sql_dialect);

Roman

P.S. I would not recommend to modify Jaybird's code to default to
dialect 1.