Search code examples
node.jsfirebirdnode-firebird

Connection Error to Firebird DB


I have attached my code and error message on the below. Can you please help me, I could not find the reason to get the error. Thanks,

// My Code

 // Node-Firebird
var Firebird = require('node-firebird');
// Options
var options = {};
//options.host = '127.0.0.1';
//options.port = 3050;
options.database = 'mydb.FDB';
options.user = 'SYSDBA';
options.password = 'masterkey';
// Query
Firebird.attach(options, function(err, db) {

    if (err)
        throw err;

    // db = DATABASE
    db.query('SOME QUERY', function(err, result) {
        // IMPORTANT: close the connection
        db.detach();
    });

});

// Error Message

/Users/bla/myfile.js:14 throw err; ^ Error: I/O error during "open" operation for file "/Users/bla/mydb.FDB", Error while trying to open file at doCallback (/Users/bla/node_modules/node-firebird/lib/index.js:1233:18) at /Users/bla/node_modules/node-firebird/lib/index.js:2897:21 at /Users/bla/node_modules/node-firebird/lib/messages.js:151:25 at search (/Users/bla/node_modules/node-firebird/lib/messages.js:117:13) at /Users/bla/node_modules/node-firebird/lib/messages.js:54:21 at FSReqWrap.wrapper as oncomplete

NOTE: Actually, I can connect the same database with c++ based driver:

var fb  = require("firebird");
var con = fb.createConnection();
con.connectSync('mydb.FDB', 'SYSDBA', 'masterkey', '');
var rs = con.querySync('SOME QUERY'); 

And when I am trying to connect via Flamerobin, it works perfectly as well. This is really weird error I guess. Any other suggestions, please?


Solution

  • I don't know the node-firebird driver, but given the behavior, one might be connecting locally (with the client library acting as a server), while the other connects through the server. This could potentially lead to the following problems:

    1. Different path resolution as you are specifying a relative path (unless mydb.FDB is defined as an alias), possibly the file /Users/bla/mydb.FDB doesn't exist
    2. Insufficient access rights, the path /Users/bla/mydb.FDB in the error suggests it is a database in a user folder which means that it is not accessible to the Firebird server process (which usually runs under the user firebird).