Nodejs Connecting the Oracle Database

Source: Internet
Author: User

NODEJS connection to Oracle database, official details of each platform document:https://github.com/oracle/node-oracledb/blob/master/INSTALL.md

My Nodejs is connected to Oracle's configuration, operating environment:

Windows7 x64

Nodejs 0.12.7

Python 2.7.10

NPM 2.11.3

Operating principle Analysis

NPM call Download, after the successful download to the Oracle client to resolve the driver package, after the successful resolution, the completion of the directory Node_modules generated oracledb module;

When the program runs, it calls the Oracle SDK to perform code compilation, the program runs logic processing, and the output page results.

Introduction to implementation steps

1, download the need for the installation of the package (2)

2. Add Environment variables

3. NPM executes the installation command

4. Query Demo Code

5. Common Error Solutions

Installation details

1, download the need for the installation of the package (2)

Download page: http://www.oracle.com/technetwork/topics/winx64soft-089540.html

Download Name:

Instantclient-basiclite-windows.x64-12.1.0.2.0.zip

Instantclient-sdk-windows.x64-12.1.0.2.0.zip

extract two files to the "C:\oracle\instantclient_12_1" file directory, do not overwrite each other.

2. Add Environment variables

Oci_inc_dir=c:\oracle\instantclient_12_1\sdk\include

Oci_lib_dir=c:\oracle\instantclient_12_1\sdk\lib\msvc

Attention! If you are installing the Oracle Server side of this machine, please add the following address to the secondary environment variable:

Oci_inc_dir = C:\app\Administrator\product\11.2.0\dbhome_1\oci\include

Oci_lib_dir = C:\app\Administrator\product\11.2.0\dbhome_1\OCI\lib\MSVC

3. NPM executes the installation command
NPM Install OracleDB
4. Query Demo Code
Router.get ('/',function(req, res, next) {varOracleDB = require (' OracleDB ')); Oracledb.getconnection ({User:' Username ', Password:' Password ', ConnectString:' 192.168.20.10:1521/ORCL '        },        function(err, connection) {if(Err) {console.error (err.message); return; } Connection.Execute ("SELECT * from Cms_file where Content_id=:id",                [1072],//Bind value For:id                function(err, result) {if(Err) {console.error (err.message); return; } res.render (' Index ', {title: ' Query information: ' +json.stringify (Result.rows)});        }); });});

After execution, show the effect,

5. Common Error Solutions

Error message, as follows:

The specified procedure could is not being found.

C:\xxx\oracledb.node ... ..

Emancipation Plan: Server installation version and environment variable Oci_inc_dir, Oci_lib_dir version does not match, the setting version is consistent, refer to step 2 above, after the configuration is complete, delete the OracleDB module downloaded before, re-download the OracleDB module (NPM Install oracledb).

Nodejs Connecting the Oracle Database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.