2

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?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

2

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).
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • You need to check the connection with localhost from both flamerobin and node-firebird driver , also the firebird is using usually a user with it's own user , you need to make sure that file permissions are granted for it (usually others should be granted rw access) In secondary example you are using the c++ driver that is using fbclient so it can access the file without the need to connect to localhost – Mariuz Oct 01 '15 at 09:11
  • @Mariuz Is this a comment that should have gone to the question itself? – Mark Rotteveel Oct 01 '15 at 09:34
  • Maybe it should , I also agree with your answer and i hope he will vote with yours – Mariuz Oct 01 '15 at 13:58
  • As I mentioned above, this is not path issue. But I will see for access rights. @Mariuz Actually, I am not using c++ driver, the second code is also nodejs. I will try your suggestions guys. Thanks! – Tural Gulmammadov Oct 01 '15 at 14:19
  • 1
    @TuralGulmammadov I think Mariuz meant that the `node-firebird` driver is an implementation of the Firebird wire protocol, while the `firebird` driver uses the Firebird native client library. – Mark Rotteveel Oct 01 '15 at 19:38