问题
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