Last active
August 29, 2015 14:16
-
-
Save lgfa29/078389f3f83095e63c96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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: ' ' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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