使用NodeJS连接到Firebird数据库时出错

时间:2018-12-05 00:44:01

标签: node.js firebird firebird2.5

我正在尝试使用NodeJS连接到Firebird数据库,并且正在使用node-firebird软件包link here,并且在尝试连接时遇到以下错误。

错误

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)

结构

┌─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()
    })
})

我的Firebase:2.5.x版,操作系统:Windows 10

TEST.fbd数据库具有一个表TEST,该表包含2个用户,分别具有idname

0 个答案:

没有答案