Subject | AW: AW: [Firebird-Java] Creating a database with a predefined page size |
---|---|
Author | Steffen Heil (Mailinglisten) |
Post date | 2017-07-07T06:51:57Z |
> >> > How can I create a database with page size 16384 in jaybird?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.
> >>
> >> FBManager.setPageSize(int), this was added in Jaybird 3, see
> >> https://www.firebirdsql.org/file/documentation/drivers_documentation/
> >> 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').
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 necessaryGood 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...
> info yourself to createDatabase:
> dpb.addArgument(ISCConstants.isc_dpb_page_size, <pagesize>), see
> https://github.com/FirebirdSQL/jaybird/blob/Branch_2_2/src/main/org/firebirdsql/management/FBManager.java#L309
>
> Note that copying the code might be simpler, because FBManager wasn't really developed with subclassing in mind.
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 )
gds.close();
}
}
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,
Steffen
[Non-text portions of this message have been removed]