Using node to connect Oracle It takes a little time to install the environment for those of you who have just started the node project or used MySQL before.
Mirror
Npm:https://www.npmjs.com/package/oracle
Taobao:https://npm.taobao.org/package/oracle
Note: on the Taobao mirror there is an eye-catching description of this library was not maintained. Oracle has made there own driver. "So I'm using the NPM image here.
install oralce Before you need to configure some environment, the above two mirrors have a description, specific can refer to: Https://github.com/xianglongxiang/node-oracledb, Here is a step I installed:
First, the Installation tool
1. Install Python 2.7:https://www.python.org/download/releases/2.7/
Installation succeeded:
2. To install GCC, Visual Studio, or similar, I am installing Visual Studio:
Visual studio:https://www.visualstudio.com/
Installation succeeded:
3. Installing Oracle's client and SDK
Client and Sdk:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
If you do not have an account, you can download it here
Client: Http://pan.baidu.com/s/1nuOg9QT
Sdk:http://pan.baidu.com/s/1ererzbs
Extract Instantclient_basic-windows.x64-12.1.0.2.0.zip and instantclient_sdk-windows.x64-12.1.0.2.0.zip to the same directory folder ", pay special attention to the same directory folder below.
Configure the folder address to the environment variable: C:\oracle\instantclient .
If the above tools are installed, there is no problem doing one of the following steps
Second, install node, here Unknown solution, specific to see node official website, https://nodejs.org/en/
Third, through visual Studio configuration
Open Visual Studio, Tools->nuget Package Manager, package management Console, enter the following command
Set Oci_lib_dir=c:\oracle\instantclient\sdk\lib\msvc
Set Oci_inc_dir=c:\oracle\instantclient\sdk\include
Iv. installing NPM To install the Oracle driver
Use the CMD or Editor console npm install Oralcedb--save
If this can be installed successfully, the Orace driver has been completed.
Five, test whether the connection is successful
var oracledb = require (' OracleDB ');
Oracledb.getconnection ({
ConnectString: "172.16.1.219/orcl",
User : "Test",
Password : "Test"
},function (err, connection) {
if (err) console.error (err.message);
Console.log ("Connection succeeded")
});
Node connects to Oracle