Loading ...
Sorry, an error occurred while loading the content.

(newbie) Embedding firebird in a java app via jaybird(?)

Expand Messages
  • judlian23
    Hi all, I am trying to embed firebird in my java application for easy deployment and to make the database transparent to the end user. As the embedded
    Message 1 of 7 , Oct 15, 2008
    • 0 Attachment
      Hi all,

      I am trying to embed firebird in my java application for easy
      deployment and to make the database transparent to the end user. As
      the embedded firebird server is done through .dll calls, I don't know
      if it's possible to embed firebird in a java app - I would assume it
      would be done through the jaybird JDBC driver, but I have not seen
      examples of it.

      Has anyone does this, does anyone know if this can be done? Are there
      examples out there? Could someone point me in the right direction?

      Please let me know.

      Help would be greatly appreciated.

      Thanks,
      Julian
    • Roman Rokytskyy
      Hi, ... Release Notes for Jaybird JDBC driver, page 10: Using Firebird client library jdbc:firebirdsql:native:host[/port]:/path/to/db.fdb
      Message 2 of 7 , Oct 15, 2008
      • 0 Attachment
        Hi,

        > I am trying to embed firebird in my java application for easy
        > deployment and to make the database transparent to the end user. As
        > the embedded firebird server is done through .dll calls, I don't know
        > if it's possible to embed firebird in a java app - I would assume it
        > would be done through the jaybird JDBC driver, but I have not seen
        > examples of it.
        >
        > Has anyone does this, does anyone know if this can be done? Are there
        > examples out there? Could someone point me in the right direction?

        Release Notes for Jaybird JDBC driver, page 10:

        "Using Firebird client library

        jdbc:firebirdsql:native:host[/port]:/path/to/db.fdb
        jdbc:firebirdsql:native://host[:port]/path/to/db.fdb

        Type 2 driver, will connect to the database using client library (either
        fbclient.dll or gds32.dll on Windows, and libfbclient.so or libgds.so on
        Linux). Requires correct installation of the client library.

        jdbc:firebirdsql:local:/path/to/db.fdb

        Type 2 driver in local mode. Uses client library as in previous case,
        however will not use socket communication, but rather access database
        directly. Requires correct installation of the client library.

        Embedded Server

        jdbc:firebirdsql:embedded:/path/to/db.fdb

        Similar to the Firebird client library, however fbembed.dll on Windows
        and libfbembed.so on Linux are used. Requires correctly installed and
        configured Firebird embedded server."

        So, in fact it is easy:

        1. place the jaybirdXX.dll in the PATH (e.g. add the current directory
        "." to your PATH)

        2. set the FIREBIRD environment variable to point to the Firebird
        Embedded installation (fbembed.dll is not enough - you need complete
        intallation)

        3. change the JDBC URL in your application

        4. start Java

        Should work. If it doesn't, try specifying the
        -Djava.library.path=<path_to_jaybird_dll> parameter to JVM.

        Roman
      • judlian23
        Hi Roman, The install was fairly easy as you said. I m not done, however. I was trying to figure out how to connect to the database, so I specified a path to
        Message 3 of 7 , Oct 22, 2008
        • 0 Attachment
          Hi Roman,

          The install was fairly easy as you said. I'm not done, however. I
          was trying to figure out how to connect to the database, so I
          specified a path to the database figuring that if it didn't exist
          firebird would create the database file for me like some of the other
          embedded apps I've used. This did not seem to be the case.

          QUESTION:
          Do I have to go through isql to create a database? Is there there a
          more transparent/embedded method?

          It seems to me that the embedded firebird version installation should
          be completely transparent to the user, and databases should not be
          created by another app prior to loading...doesn't it defeat the
          purpose of making your server embedded? I believe I could've just as
          easily used firebird through the standalone app/service installation.
          Maybe I'm missing something?

          Thanks for the quick reply and I hope to hear from you soon.

          Julian

          --- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...> wrote:
          >
          > Hi,
          >
          > > I am trying to embed firebird in my java application for easy
          > > deployment and to make the database transparent to the end user. As
          > > the embedded firebird server is done through .dll calls, I don't know
          > > if it's possible to embed firebird in a java app - I would assume it
          > > would be done through the jaybird JDBC driver, but I have not seen
          > > examples of it.
          > >
          > > Has anyone does this, does anyone know if this can be done? Are there
          > > examples out there? Could someone point me in the right direction?
          >
          > Release Notes for Jaybird JDBC driver, page 10:
          >
          > "Using Firebird client library
          >
          > jdbc:firebirdsql:native:host[/port]:/path/to/db.fdb
          > jdbc:firebirdsql:native://host[:port]/path/to/db.fdb
          >
          > Type 2 driver, will connect to the database using client library
          (either
          > fbclient.dll or gds32.dll on Windows, and libfbclient.so or
          libgds.so on
          > Linux). Requires correct installation of the client library.
          >
          > jdbc:firebirdsql:local:/path/to/db.fdb
          >
          > Type 2 driver in local mode. Uses client library as in previous case,
          > however will not use socket communication, but rather access database
          > directly. Requires correct installation of the client library.
          >
          > Embedded Server
          >
          > jdbc:firebirdsql:embedded:/path/to/db.fdb
          >
          > Similar to the Firebird client library, however fbembed.dll on Windows
          > and libfbembed.so on Linux are used. Requires correctly installed and
          > configured Firebird embedded server."
          >
          > So, in fact it is easy:
          >
          > 1. place the jaybirdXX.dll in the PATH (e.g. add the current directory
          > "." to your PATH)
          >
          > 2. set the FIREBIRD environment variable to point to the Firebird
          > Embedded installation (fbembed.dll is not enough - you need complete
          > intallation)
          >
          > 3. change the JDBC URL in your application
          >
          > 4. start Java
          >
          > Should work. If it doesn't, try specifying the
          > -Djava.library.path=<path_to_jaybird_dll> parameter to JVM.
          >
          > Roman
          >
        • Roman Rokytskyy
          ... Correct. ... Yes, there is class org.firebirdsql.management.FBManager, you can create database with it. FBManager manager = new FBManager( EMBEDDED );
          Message 4 of 7 , Oct 22, 2008
          • 0 Attachment
            > The install was fairly easy as you said. I'm not done, however. I
            > was trying to figure out how to connect to the database, so I
            > specified a path to the database figuring that if it didn't exist
            > firebird would create the database file for me like some of the other
            > embedded apps I've used. This did not seem to be the case.

            Correct.

            > QUESTION:
            > Do I have to go through isql to create a database? Is there there a
            > more transparent/embedded method?

            Yes, there is class org.firebirdsql.management.FBManager, you can create
            database with it.

            FBManager manager = new FBManager("EMBEDDED");
            manager.start();
            manager.createDatabase("/path/to/your/db.fdb", null, null);
            manager.stop();

            The last two parameters are user name and password. If FBManager has
            problems with nulls there, put some dummy values (and report a bug about
            NullPointerException into the tracker).

            As to the manageability. Jaybird provides classes for most database
            management operations, including creating and dropping databases, backup
            and restore, property management (e.g. set read only, run sweep, etc.).
            Usually these operations require more application-related knowledge and
            cannot be handled automatically for all cases, that is why we provide
            methods to do operations, but not do them ourselves.

            Roman
          • judlian23
            Is there a way to use FBManager to specify the page size? Also, is there a place I can find an API for FBManager? I ve looked in a lot of places including the
            Message 5 of 7 , Oct 28, 2008
            • 0 Attachment
              Is there a way to use FBManager to specify the page size?

              Also, is there a place I can find an API for FBManager? I've looked
              in a lot of places including the jaybird wiki site, and I can't find much.

              It's been a little frustrating to find manuals or documentation for
              everything.

              Please help.

              -Julian

              --- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...> wrote:
              >
              > > The install was fairly easy as you said. I'm not done, however. I
              > > was trying to figure out how to connect to the database, so I
              > > specified a path to the database figuring that if it didn't exist
              > > firebird would create the database file for me like some of the other
              > > embedded apps I've used. This did not seem to be the case.
              >
              > Correct.
              >
              > > QUESTION:
              > > Do I have to go through isql to create a database? Is there there a
              > > more transparent/embedded method?
              >
              > Yes, there is class org.firebirdsql.management.FBManager, you can
              create
              > database with it.
              >
              > FBManager manager = new FBManager("EMBEDDED");
              > manager.start();
              > manager.createDatabase("/path/to/your/db.fdb", null, null);
              > manager.stop();
              >
              > The last two parameters are user name and password. If FBManager has
              > problems with nulls there, put some dummy values (and report a bug
              about
              > NullPointerException into the tracker).
              >
              > As to the manageability. Jaybird provides classes for most database
              > management operations, including creating and dropping databases,
              backup
              > and restore, property management (e.g. set read only, run sweep, etc.).
              > Usually these operations require more application-related knowledge and
              > cannot be handled automatically for all cases, that is why we provide
              > methods to do operations, but not do them ourselves.
              >
              > Roman
              >
            • judlian23
              ... By everything I mean mostly with firebird documentation...not Jaybird. I don t understand why firebird has two websites - navigation is also a little
              Message 6 of 7 , Oct 28, 2008
              • 0 Attachment
                > It's been a little frustrating to find manuals or documentation for
                > everything.

                By everything I mean mostly with firebird documentation...not Jaybird.
                I don't understand why firebird has two websites - navigation is also
                a little sloppy.

                --- In Firebird-Java@yahoogroups.com, "judlian23" <jtb3f@...> wrote:
                >
                > Is there a way to use FBManager to specify the page size?
                >
                > Also, is there a place I can find an API for FBManager? I've looked
                > in a lot of places including the jaybird wiki site, and I can't find
                much.
                >
                > It's been a little frustrating to find manuals or documentation for
                > everything.
                >
                > Please help.
                >
                > -Julian
                >
                > --- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@> wrote:
                > >
                > > > The install was fairly easy as you said. I'm not done, however. I
                > > > was trying to figure out how to connect to the database, so I
                > > > specified a path to the database figuring that if it didn't exist
                > > > firebird would create the database file for me like some of the
                other
                > > > embedded apps I've used. This did not seem to be the case.
                > >
                > > Correct.
                > >
                > > > QUESTION:
                > > > Do I have to go through isql to create a database? Is there there a
                > > > more transparent/embedded method?
                > >
                > > Yes, there is class org.firebirdsql.management.FBManager, you can
                > create
                > > database with it.
                > >
                > > FBManager manager = new FBManager("EMBEDDED");
                > > manager.start();
                > > manager.createDatabase("/path/to/your/db.fdb", null, null);
                > > manager.stop();
                > >
                > > The last two parameters are user name and password. If FBManager has
                > > problems with nulls there, put some dummy values (and report a bug
                > about
                > > NullPointerException into the tracker).
                > >
                > > As to the manageability. Jaybird provides classes for most database
                > > management operations, including creating and dropping databases,
                > backup
                > > and restore, property management (e.g. set read only, run sweep,
                etc.).
                > > Usually these operations require more application-related
                knowledge and
                > > cannot be handled automatically for all cases, that is why we provide
                > > methods to do operations, but not do them ourselves.
                > >
                > > Roman
                > >
                >
              • Roman Rokytskyy
                ... No. At the moment Jaybird does not support setting the database parameters on creation (page size, character set). The default character set is not that
                Message 7 of 7 , Oct 28, 2008
                • 0 Attachment
                  > Is there a way to use FBManager to specify the page size?

                  No. At the moment Jaybird does not support setting the database
                  parameters on creation (page size, character set).

                  The default character set is not that big issue, since it is possible to
                  change it right after creation by direct update of the rdb$database
                  table. But the page size is not that easy - at the moment the only
                  workaround is to restore the database from backup.

                  > Also, is there a place I can find an API for FBManager? I've looked
                  > in a lot of places including the jaybird wiki site, and I can't find much.

                  What about Javadoc in the Jaybird 2.1.x archive?

                  > It's been a little frustrating to find manuals or documentation for
                  > everything.
                  ...
                  > By everything I mean mostly with firebird documentation...not Jaybird.
                  > I don't understand why firebird has two websites - navigation is also
                  > a little sloppy.

                  Re. Firebird website - we are currently in the process of website
                  redesign, so any suggestion how to improve it are welcome.

                  As to Jaybird documentation. I have wrote a programmers reference, it is
                  at the moment in OpenOffice.org format and not yet published on the
                  web, only in the Firebird documentation project CVS. But we are working
                  in that direction.

                  Roman
                Your message has been successfully submitted and would be delivered to recipients shortly.