Skip to content

Instantly share code, notes, and snippets.

@lgfa29
Last active August 29, 2015 14:16
Show Gist options
  • Save lgfa29/078389f3f83095e63c96 to your computer and use it in GitHub Desktop.
Save lgfa29/078389f3f83095e63c96 to your computer and use it in GitHub Desktop.
$ node
> .load test.js
...
> connection opened!
[ { ... } ]
done
> .load test.js
...
> { [Error: [IBM][CLI Driver] SQL1776N The command cannot be issued on an HADR database. Reason code = "1".
]
error: '[node-odbc] SQL_ERROR',
message: '[IBM][CLI Driver] SQL1776N The command cannot be issued on an HADR database. Reason code = "1".\n',
state: ' ' }
var util = require('util');
var ibmdb = require('ibm_db');
var database = "";
var hostname = "";
var username = "";
var password = "";
var port = "";
var connString = util.format("DRIVER={DB2};DATABASE=%s;HOSTNAME=%s;UID=%s;PWD=%s;PORT=%s;PROTOCOL=TCPIP",
database, hostname, username, password, port);
ibmdb.open(connString, function (err,conn) {
if (err) return console.log(err);
console.log('connection opened!');
conn.query('select * from mdl_user where id = ? with ur', [1], function (err, data) {
if (err) console.log(err);
console.log(data);
conn.close(function () {
console.log('done');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment