Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save umidjons/68308937ad7c542cd6193b82df94afa9 to your computer and use it in GitHub Desktop.
Save umidjons/68308937ad7c542cd6193b82df94afa9 to your computer and use it in GitHub Desktop.
Installing node-oracledb package on Ubuntu

Installing node-oracledb package on Ubuntu

Instruction

Installing Oracle 11g Client in Ubuntu 14.04 LTS instruction

Download following archives

instantclient-basic-linux.x64-12.1.0.2.0.zip
instantclient-sqlplus-linux.x64-12.1.0.2.0.zip
instantclient-sdk-linux.x64-12.1.0.2.0.zip

Set Environment variables

I set following variables in .bashrc

export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/:$LD_LIBRARY_PATH
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export OCI_INC_DIR=$ORACLE_HOME/sdk/include
export PATH=$PATH:$ORACLE_HOME/bin

Installing oracledb package

cd myproject
sudo bash
npm i oracledb

Test connection string via sqlplus

sqlplus 'myuser/mypassword@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.4)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myora)))'

Connecting to Oracle in JS

var oracle = require("oracledb");

var dbconfig = {
	"user": "myuser",
	"password": "mypassword",
	"connectString": "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.4)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=myora)))"
};

oracle.getConnection(dbconfig, function (err, conn) {
    if (err) {
        return console.error(err);
    }
    
    console.log('Success');
    
    // use conn to invoke queries
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment