Subject | Re: [Firebird-Java] Setting database page size |
---|---|
Author | Alec Swan |
Post date | 2009-08-18T16:56Z |
Mark, I understood your suggestion. Thanks.
However, I was wondering if it is possible to create a database using
"CREATE DATABASE" sql statement when running in embedded mode?
However, I was wondering if it is possible to create a database using
"CREATE DATABASE" sql statement when running in embedded mode?
On Tue, Aug 18, 2009 at 10:10 AM, Mark Rotteveel <Avalanche1979@...>wrote:
>
>
> I am not talking about using the CREATE DATABASE statement, Jaybird uses
> the internal API of Firebird.
>
> I think you will need to subclass FBManager and replace the method
> createDatabase(...) with code that also adds the
> DatabaseParameterBuffer.PAGE_SIZE to the buffer with the correct value.
>
> eg: (set page size to 8192, *UNTESTED*, line to add marked with >>NEW>>)
>
> public void createDatabase (String fileName, String user, String
> password)
> throws Exception
> {
> IscDbHandle db = null;
> db = gds.createIscDbHandle();
> try {
> DatabaseParameterBuffer dpb = c.deepCopy();
> dpb.addArgument(DatabaseParameterBuffer.USER_NAME, user);
> dpb.addArgument(DatabaseParameterBuffer.PASSWORD,
> password);
> gds.iscAttachDatabase(getConnectString(fileName), db, dpb);
>
> // if forceCreate is set, drop the database correctly
> // otherwise exit, database already exists
> if (forceCreate)
> gds.iscDropDatabase(db);
> else {
> gds.iscDetachDatabase(db);
> return; //database exists, don't wipe it out.
> }
> } catch (GDSException e) {
> // we ignore it
> }
>
> db = gds.createIscDbHandle();
> try {
> DatabaseParameterBuffer dpb = c.deepCopy();
> dpb.addArgument(DatabaseParameterBuffer.USER_NAME, user);
> dpb.addArgument(DatabaseParameterBuffer.PASSWORD, password);
> >>NEW>> dpb.AddArgument(DatabaseParameterBuffer.PAGE_SIZE, 8192);
> gds.iscCreateDatabase(getConnectString(fileName), db, dpb);
> gds.iscDetachDatabase(db);
> }
> catch (Exception e) {
> if (log!=null)
> {
> log.error("Exception creating database", e);
> }
> throw e;
>
> }
> }
>
> Alec Swan wrote:
> > I know I can specify page size in "create database" statement, but I
> don't
> > understand where in the code to issue this statement when running in
> > embedded mode.
> >
> > On Tue, Aug 18, 2009 at 9:41 AM, Mark Rotteveel <Avalanche1979@...<Avalanche1979%40gmx.net>
> >wrote:
> >
> >>
> >> As far as I can see in the documentation, I don't think you can set the
> >> pagesize with FBManager. You probably can do something yourself by
> >> duplicating the code used in
> >> org.firebirdsql.management.FBManager.createDatabase and add a
> >> DatabaseParameterBuffer.PAGE_SIZE to the parameterbuffer (although I am
> >> not 100% sure that will work).
> >>
> >> Mark
> >>
> >>
> >> Alec Swan wrote:
> >>> How can I configure the database page size when creating a new database
> >>> using FBManager?
> >>>
> >>> Here is my current code:
> >>>
> >>> // start embedded Firebird server
> >>> FBManager manager = new FBManager("EMBEDDED");
> >>> manager.start();
> >>> manager.setForceCreate(true);
> >>> manager.createDatabase(databaseDbFile.getAbsolutePath(), "", "");
>
> --
> Mark Rotteveel
>
>
[Non-text portions of this message have been removed]