Solved

Getting Firebird embedded working in java

Posted on 2006-11-28
13
8,229 Views
Last Modified: 2013-12-09
I am trying to get my java application to connect to a firebird embedded database and so far i keep getting errors currently i am getting this error

org.firebirdsql.gds.impl.jni.InternalError: FirebirdApiBinding::Initialize - Could not find or load the GDS32.DLL
        at org.firebirdsql.gds.impl.jni.JniGDSImpl.nativeInitilize(Native Method)
        at org.firebirdsql.gds.impl.jni.JniGDSImpl.attemptToLoadAClientLibraryFromList(JniGDSImpl.java:85)
        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:219)


In order to get to this point i dropped both the fbembed.dll and the gds32.dll(which is actually just the renamed fbembed.dll) into the c:\windows\system32 folder.

I then tried dropping all kinds of other files including the intl folder from the firebird embedded download and the firebird.conf and firebird.msg

I also tried putting them directly in my lib folder it still cannot find the the gds32.dll.  

Any ideas on what i am doing wrong or where the gds32.dll should go?

oh yeah the connection url i am using in my project is this
        try{

            Connection con = null;
            Driver d = (Driver)Class.forName( "org.firebirdsql.jdbc.FBDriver" ).newInstance();
            con = DriverManager.getConnection("jdbc:firebirdsql:embedded:C:\\Database\\userdb.fdb", "sysdba", "masterkey");
            System.out.println("sqlUtilities.getResultSet:Database connection established");
            Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        }catch (java.sql.SQLException e){
            System.out.println("exception: Message-" + e.getMessage() +" ToString-" + e.toString());
            e.printStackTrace();
}

the error occurs after the DriverManager.getConnection

and i should add also i have firebird 2.0 superserver installed and running on my system possibly is this causing a conflict?
0
Comment
Question by:ethnarch
  • 9
  • 4
13 Comments
 
LVL 19

Expert Comment

by:NickUpson
ID: 18034830
to run 2 versions on the same machine at the same time you need to configure one to run on a non-default port number, say 1.5 on 3050 (default) & 2.0 on 3059 (say)

once that is done, please try using the commandline isql tool to connect to the database (correct version)
isql localhost:c:\dbs\mydb.fdb -user sysdba -password masterkey
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18035983
how would i change the port number on the embedded version?
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18036098
I managed to find a setting in the firebird.conf which says
RemoteServicePort

and i uncommented it and change it to look like this

RemoteServicePort = 3059

that gave me the same error as above

Ok i went back to what the readme file says to do and i uninstalled firebird 2.0 superserver and i get this error.


exception: Message-Unexpected exception caught. ToString-org.firebirdsql.gds.impl.jni.InternalError: Unexpected exception caught.
org.firebirdsql.gds.impl.jni.InternalError: Unexpected exception caught.
        at org.firebirdsql.gds.impl.jni.JniGDSImpl.native_isc_attach_database(Native Method)
        at org.firebirdsql.gds.impl.jni.BaseGDSImpl.iscAttachDatabase(BaseGDSImpl.java:118)
        at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:89)
        at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:470)
        at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)
        at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:119)


I setup the file directly like it says in the readme
  c:\my_app\app.exe
  c:\my_app\gds32.dll
  c:\my_app\ib_util.dll
  c:\my_app\icudt30.dll
  c:\my_app\icuin30.dll
  c:\my_app\icuuc30.dll
  c:\my_app\firebird.conf
  c:\my_app\firebird.msg
  c:\my_app\intl\fbintl.dll
  c:\my_app\intl\fbintl.conf
  c:\my_app\udf\fbudf.dll

this didn't work either
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 18039953
did you restart the firebird service that relates to the firebird.conf file you changed, it's only read on startup

please try using isql as described, we need to decide if the problem is firebird or java
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18041218
there is no service it's the embedded version
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18041427
Yes isql can connect to it  i did not know if i was connected so i just ran a query to test(as i have never used isql yet)

Use CONNECT or CREATE DATABASE to specify a database
SQL> CONNECT C:\zee03\Database\USERDB.FDB
CON> user 'SYSDBA' password 'masterkey';
Database:  C:\zee03\Database\USERDB.FDB, User: SYSDBA
SQL> SELECT COUNT(*) FROM ORDERS
CON> go;

       COUNT
============
           0

SQL>
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 2

Author Comment

by:ethnarch
ID: 18042646
Another thing i just found out was that if i change the connection string from

con = DriverManager.getConnection("jdbc:firebirdsql:embedded:C:\\zee03\\Database\\userdb.fdb", "sysdba", "masterkey");
           
to:

con = DriverManager.getConnection("jdbc:firebirdsql:localhost:C:\\zee03\\Database\\userdb.fdb", "sysdba", "masterkey");
           
All of the documentation at firebird says i should be using the embedded tag not localhost so i am assuming it's somehow using the installed firebird server to make the connection(not say i have any idea how this works thats just my guess).  

I want to use the embedded database in my application however so i should not have to install the server on my system just the files for the embedded version.
0
 
LVL 19

Expert Comment

by:NickUpson
ID: 18043271
yes it's using which ever version you installed as a server, most commonly the server version is used for development as you can have multiple connection open at once, then embeded for deployment. I think the problem is that you are trying to have both embedded & server installed at once.

I would remove one (completely), get the other working, edit firebird.conf to move it's port, then install the other and get that working, once each work via isql you know it's just the java params that need to change
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18050844
I have a problem, ehh if i uninstall firebird 2.0 superserver than i don't seem to have isql on my system and i can't seem to find it online to download anywhere. As it is not included with the embedded download package.  Do you know where i can find it.  

I do have flamerobin installed on my computer and no it cannot connect without the superserver installed on my computer it gives me an error.

Context: Database: Connect
Message: isc_attach_Database failed

SQL Message: -904
can't format message 13:96 --message c:\Program Files\firebird.msg  not found
Engine Code 335544375


This is kind of strange since i never installed firebird to the program files folder it was installed to the default folder
C:\Program Files\Firebird\Firebird_2_0\
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18050938
ok i got a connection with flamerobin after installing a bunch of files and restarting it i got a connection to the database.
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18050985
I tried connecting again with java same error

exception: Message-Unexpected exception caught. ToString-org.firebirdsql.gds.impl.jni.InternalError: Unexpected exception caught.
org.firebirdsql.gds.impl.jni.InternalError: Unexpected exception caught.
        at org.firebirdsql.gds.impl.jni.JniGDSImpl.native_isc_attach_database(Native Method)
        at org.firebirdsql.gds.impl.jni.BaseGDSImpl.iscAttachDatabase(BaseGDSImpl.java:118)
        at org.firebirdsql.jca.FBManagedConnection.<init>(FBManagedConnection.java:89)
        at org.firebirdsql.jca.FBManagedConnectionFactory.createManagedConnection(FBManagedConnectionFactory.java:470)
        at org.firebirdsql.jca.FBStandAloneConnectionManager.allocateConnection(FBStandAloneConnectionManager.java:69)
        at org.firebirdsql.jdbc.FBDataSource.getConnection(FBDataSource.java:119)
        at org.firebirdsql.jdbc.FBDriver.connect(FBDriver.java:131)

I could just be putting the embedded files in the wrong place
I am using netbeans as my IDE and it has the usual folder arrangement

My Project
     build
     dist
     nbproject
     src
     test


I placed my embedded files in the My Project folder which now looks like this

My Project
     build
     dist
     intl  --firebird embedded folder
     nbproject
     src
     test
     udf --firebird embedded folder
    fbembed.dll -- embedded file
    gds32.dll  -- embedded file
    fbclient.dll --embedded file
    jaybird21.dll -- embedded file
0
 
LVL 19

Accepted Solution

by:
NickUpson earned 250 total points
ID: 18051817
ok, firebird seems to be ok, the dll files are where I'd expect and you can connect from flamerobin so the problem now is java, which I'm not an expert with
0
 
LVL 2

Author Comment

by:ethnarch
ID: 18052854
I see so i guess i'll switch forums just incase i'll keep this question open for a couple of days. Thankyou for the help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In today’s complex data management environments, it is not unusual for UNIX servers to be dedicated to a particular department, purpose, or database.  As a result, a SAS® data analyst often works with multiple servers, each with its own data storage…
I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now