Setup for Node.js
You need to install the node-oracledb driver to successfully configure a connection to a TimesTen database in Node.js.
Task 1: Install the node-oracledb Driver
There are several approaches for installing the node-oracledb driver. Choose the approach that is most suitable for your setup and environment.
-
Install the node-oracledb driver from the npm package manager. See Quick Start node-oracledb Installation.
-
Install the node-oracledb driver from source code. You can either perform the installation using GitHub or opensource.oracle.com. See Installing node-oracledb from Source Code.
-
Install the python-oracledb driver without Internet access. See Installing node-oracledb Without Internet Access.
Information for all scenarios is available at Installing node-oracledb.
Task 2: Initialize the node-oracledb Driver
To enable Thick mode for the node-oracledb driver, call the
oracledb.init_oracle_client()
synchronous function in your application
before creating any connection. See Enabling node-oracledb Thick Mode.
This example calls the oracledb.init_oracle_client()
function
without a libDir
attribute to ensure it uses the PATH
environment variable set by ttenv
script. See Task 2: Set the TimesTen Environment.
var oracledb = require('oracledb');
oracledb.initOracleClient();
Task 3: Configure Connections to TimesTen in Node.js
This example uses a TNS name for a Node.js connection string:
function connect(cb) {
oracledb.getConnection({
user : "appuser",
password : "password",
connectString : "sampledbconn"
} ,
cb);
}
This example uses an Easy Connect string that specifies a direct connection to TimesTen:
function connect(cb) {
oracledb.getConnection({
user : "appuser",
password : "password",
connectString : "myhost/sampledb:timesten_direct"
} ,
cb);
}