How to Open a JDBC Connection to Firebird

In order to connect to a Firebird database, you'll need the Firebird JDBC driver (e.g. jaybird-full-2.2.3.jar). You'll also need the Firebird runtime libraries. You can install the libraries using the standard installer or you can simply download the libraries in a zip file (e.g. Firebird-2.5.2.26540-0_x64_embed.zip). In either case, your Java application will need to be able to load both the core Firebird runtime libraries and the Jaybird library so make sure your environment is set up correctly.

Example

Firebird can be run in either server mode or embedded mode. Here's an example of how to connect to Firebird using the embedded mode. This will create a single database file on the file system.

            String path = file.toString().replace("\\", "/");
            if (!file.exists()){
                org.firebirdsql.management.FBManager manager =
                new org.firebirdsql.management.FBManager(
                    org.firebirdsql.gds.impl.GDSType.getType("EMBEDDED")
                );
                manager.start();
                manager.createDatabase(path, "", "");
                manager.stop();
            }

            java.sql.Driver driver = 
                (java.sql.Driver) Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();

            java.sql.Connection conn =
                driver.connect("jdbc:firebirdsql:embedded:" + path, new java.util.Properties());

References

  • http://www.firebirdsql.org/en/about-firebird/
  • http://www.firebirdfaq.org/faq350/
  • http://www.firebirdsql.org/en/firebird-2-5-2-upd1/