Skip to main content

ODBC Example


This page holds a better ODBC usage example

Click here to expand Table of Contents

JavaScript ODBC Example


var db = new ODBC("dsnName", "username", "password");
var sql = "select * from users";


if (!db.query(sql))
session.hangup(); //might want to say something nice instead.

while (db.nextRow())
row = db.getData();
console_log("debug", "UserName: " + row["user_name"]);


If you see get an error message like this:

[ERR] mod_spidermonkey.c:2697 js_api_use() Error loading ODBC
[ERR] test-odbc.js:3 mod_spidermonkey() ReferenceError: ODBC is not defined

Ensure that the mod_spidermonkey_odbc module is installed and successfully loaded at start up. It (and all other spidermonkey extensions) is configured to load from the spidermonkey.conf.xml.

See Also