Question

I've been working on a program that connects to a Firebird database and listens for events. I'm trying to get it to work with an embedded database.

EventManager em = new FBEventManager(GDSType.getType("EMBEDDED"));
em.setHost("localhost");
em.setDatabase("C:\\test.fdb");
em.connect();
Exception in thread "main" java.lang.RuntimeException: Failed to initialize Jaybird native library. This is most likely due to a failure to load the firebird client library.
    at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:106)
    at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:31)
    at org.firebirdsql.gds.impl.jni.EmbeddedGDSImpl.<init>(EmbeddedGDSImpl.java:21)
    at org.firebirdsql.gds.impl.jni.EmbeddedGDSFactoryPlugin.getGDS(EmbeddedGDSFactoryPlugin.java:40)
    at org.firebirdsql.gds.impl.GDSFactory.getGDSForType(GDSFactory.java:220)
    at org.firebirdsql.event.FBEventManager.<init>(FBEventManager.java:91)
    at eventhandler.FirebirdEventMaster.<init>(FirebirdEventMaster.java:42)
    at eventhandler.FirebirdEventMaster.getInstance(FirebirdEventMaster.java:33)
    at eventhandler.Driver.main(Driver.java:13)

After much googling, I've tried...

"VM Options": -Djava.library.path="C:\Users\jrile\Downloads\Jaybird-2.2.3JDK_1.6"

"FIREBIRD" and "PATH" system variable: "C:\Users\jrile\Downloads\Firebird-2.5.2.26540-0_x64_embed"

Using Windows 64 bit and Firebird Embedded 64 bit. Any help would be much appreciated

Was it helpful?

Solution

I created a very simple program to connect to Firebird embedded:

package pkg;

import java.sql.*;

public class MainClass {

    public static void main(String[] args) throws SQLException {
        try (Connection con = DriverManager
              .getConnection("jdbc:firebirdsql:embedded:D:/data/db/testdatabase.fdb", "sysdba", "")) {
            try (
                Statement stmt = con.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT * FROM RDB$DATABASE");
            ) {
                while (rs.next()) {
                    System.out.println(rs.getString(2));
                }
            }
        }
    }
}

This is in a layout:

src
+--pkg
   +--MainClass.java

I opened a command prompt, and went to the src folder and compiled with:

javac -cp . pkg\MainClass.java

I updated my path to include the 64 bit Firebird embedded files

...\src>SET PATH=%PATH%;D:\Development\project\JaybirdEclipse\native_test_files_64bit

..\src>java -cp .;D:\Development\libs\Jaybird-2.2.3JDK_1.7\jaybird-full-2.2.3.jar 
       -Djava.library.path=D:\Development\libs\Jaybird-2.2.3JDK_1.7 
        pkg.MainClass
160

Where 160 is the value of column RDB$RELATION_ID in table RDB$DATABASE in my database.

Now if instead I execute with the 32 bit JRE, I get the exact same error as you are having:

...\src>"C:\Program Files (x86)\java\jre7\bin\java" 
        -cp .;D:\Development\libs\Jaybird-2.2.3JDK_1.7\jaybird-full-2.2.3.jar 
        -Djava.library.path=D:\Development\libs\Jaybird-2.2.3JDK_1.7 
        pkg.MainClass
Exception in thread "main" java.lang.RuntimeException: Failed to initialize 
Jaybird native library. This is most likely due to a failure to load the firebird 
client library.

Note that this is the same error you get when you don't include Firebird embedded on your PATH (or in the root folder of your Java application). My guess is that you are trying to run this with the 32 bit Java instead of the 64 bit version.

OTHER TIPS

Same error on Windows 7 64 bits.

The problem is that Firebird embedded need more thatn just the firebird driver and jaybird dll. It requires firebird client DLL and the "intl" folder (plus possibly other stuff).

Solved by downloading the embedded Firebird file fro sourceforge and unzip it into my application root directory.

No need to modify the Windows PATH variable.

To distribute your software, make sure all Firebird files are included and accessible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top