Error when connecting to Firebird database with NodeJS

Deadly 提交于 2019-12-24 08:17:33

问题


I'm trying to connect to a Firebird database with NodeJS, and I'm using the node-firebird package link here, and am having the following error when trying to connect.

Error

node index.js
Error: Connection is closed.
    at exports.Connection.Connection._queueEvent (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:3117:22)
    at exports.Connection.Connection.connect (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:3152:10)
    at C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:1587:13
    at Socket.<anonymous> (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:2828:17)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at TCP._handle.close [as _onclose] (net.js:561:12)
C:\Users\JEFTER\Documents\firebird-node-dev\index.js:19
    db.query('SELECT * FROM TEST', function(err, result) {
       ^

TypeError: Cannot read property 'query' of undefined
    at C:\Users\JEFTER\Documents\firebird-node-dev\index.js:19:8
    at doError (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:1244:9)
    at C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:1589:17
    at exports.Connection.Connection._queueEvent (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:3117:13)
    at exports.Connection.Connection.connect (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:3152:10)
    at C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:1587:13
    at Socket.<anonymous> (C:\Users\JEFTER\Documents\firebird-node-dev\node_modules\node-firebird\lib\index.js:2828:17)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at TCP._handle.close [as _onclose] (net.js:561:12)

Structure

┌─data
│ └─TEST.FDB
├─node_modules
├─index.js
├─package.json
└─package-lock.json

index.js

const firebird = require('node-firebird')
const options = {
    host: '127.0.0.1',
    port: 3050,
    database: 'C:/Users/JEFTER/Documents/firebird-node-dev/data/TEST.FDB',
    user: 'SYSDBA',
    password: 'masterkey',
    lowercase_keys: false, // set to true to lowercase keys
    role: null,            // default
    pageSize: 4096         // default when creating database
}

firebird.attach(options, (err, db) => {

    if (err)
        console.log(err)

    // db = DATABASE
    db.query('SELECT * FROM TEST', (err, result) => {
        // IMPORTANT: close the connection
        db.detach()
    })
})

My Firebase: version 2.5.x, OS: Windows 10

The TEST.fbd database has a table TEST with 2 users with id and name.

来源:https://stackoverflow.com/questions/53623556/error-when-connecting-to-firebird-database-with-nodejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!