Subject AW: AW: [Firebird-Java] Creating a database with a predefined page size
Author Steffen Heil (Mailinglisten)
> >> > How can I create a database with page size 16384 in jaybird?
> >>
> >> FBManager.setPageSize(int), this was added in Jaybird 3, see
> >>
> >> java/3.0.1/docs/org/firebirdsql/management/FBManager.h
> >> tml#setPageSize-int-
> >
> > Is there any way to do it with jaybird 2 ?
> > We are in the process of switching to firebird 3, but we want to stay
> > with jaybird 2 for now, as we don't want to switch to another
> > connection pool at the same time.
> Jaybird 3 does not imply that you need to use Firebird 3, and the reverse is only true if you want to use the new more secure
> authentication model. Jaybird 3 supports Firebird 2 and higher (and technically works fine with Firebird 1.0 and 1.5, it is just 'not
> supported').

Yes I know, jaybird 3 can work with firebird 3, but for technical reasons we have to switch to firebird 3 now and I don't want to change both sides in the same step.
Especially as we are using jaybird 2s FBWrappingDataSource, and moving on from that is more work than we can handle right now.

> In any case, to get the same effect with Jaybird 2, you could subclass FBManager or copy and modify the code and add the necessary
> info yourself to createDatabase:
> dpb.addArgument(ISCConstants.isc_dpb_page_size, <pagesize>), see
> Note that copying the code might be simpler, because FBManager wasn't really developed with subclassing in mind.

Good idea. Usually I look into such code myself and try such modification, but for some reason I hesitated to do so for jaybird. Basically I believed such a change would require much more than a new pair in a map...

I ended up with the following:

public static void createDatabase( String database, int dialect, String charset, int pageSize, boolean forcedWrites, String user, String password )
throws Exception
GDS gds = null;
try {
gds = GDSFactory.getGDSForType( GDSFactory.getDefaultGDS().getType() );
IscDbHandle db = gds.createIscDbHandle();
db = gds.createIscDbHandle();
DatabaseParameterBuffer dpb = gds.createDatabaseParameterBuffer();
dpb.addArgument( DatabaseParameterBuffer.DUMMY_PACKET_INTERVAL, new byte[] { 120, 10, 0, 0 } );
dpb.addArgument( DatabaseParameterBuffer.USER_NAME, user );
dpb.addArgument( DatabaseParameterBuffer.PASSWORD, password );
dpb.addArgument( DatabaseParameterBuffer.SET_DB_SQL_DIALECT, dialect );
dpb.addArgument( DatabaseParameterBuffer.SQL_DIALECT, dialect );
dpb.addArgument( DatabaseParameterBuffer.PAGE_SIZE, pageSize );
dpb.addArgument( DatabaseParameterBuffer.FORCE_WRITE, forcedWrites ? 1 : 0 );
dpb.addArgument( DatabaseParameterBuffer.SET_DB_CHARSET, charset );
gds.iscCreateDatabase( database, db, dpb );
gds.iscDetachDatabase( db );
} finally {
if ( gds != null )

That also solves the problem of having to change the database charset afterwards and allows control over forced writes.

Thanks a lot.

(I do have a followup question about server versions, but as that might be interesting for others, I will start a new thread.)

Thank you very much,

[Non-text portions of this message have been removed]