Software Required
- Windows 7.1 SDK (Microsoft Windows SDK for Windows 7 and .NET Framework 4.0)
http://www.microsoft.com/en-us/download/details.aspx?id=8279 - Visual C++ 2010 Express
http://www.visualstudio.com/en-us/downloads#d-2010-express - Python 2.7
https://www.python.org/downloads/ - Oracle Download
Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications ( instantclient-basic-windows.x64-12.1.0.2.0)
*Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client (instantclient-sdk-windows.x64-12.1.0.2.0)
http://www.oracle.com/technetwork/topics/winx64soft-089540.html - Node package For Oracle
https://github.com/joeferner/node-oracle
Setup
Step 1
Install Windows 7 SDK
1) Uninstall any c++ redistributable you have on your pc.
2) If you run in to problem installing the windows 7 sdk , try doing what is provided at this help (http://ctrlf5.net/?p=184)
Step 2
Install Visual C++ 2010 Express
Step 3
Download and install Python
Step 4
Download the Oracle Basic + SDK. (kindly download 64 bit /32 bit depending on your OS)
Extract it at one place
C:\oracle\instantclient_12_1_64
Step 5
Download the node-oracle zip and extract it at
C:\oracle\node-oracle-master
Step 6
set the following variable or create a bat file that you can run.
set OCI_LIB_DIR=C:\oracle\instantclient_12_1_64\sdk\lib\msvc\vc10
set OCI_INCLUDE_DIR=C:\oracle\instantclient_12_1_64\sdk\include
set OCI_VERSION=12
set NLS_LANG=.UTF8 # Optional, but required to support international characters
Path=%PATH%;C:\oracle\instantclient_12_1_64\vc10;C:\oracle\instantclient_12_1_64;C:\Users\jignesh.rangwala\AppData\Roaming\npm;C:\Python27\python.exe;C:\Python27\pythonw.exe
Step 7
Launch the Windows SDK 7.1 Command Prompt, go to the directory of your node-oracle module (C:\oracle\node-oracle-master)
If any where in this step you get file permission errors open the Windows SDK 7.1 Command Prompt as Administrator
1) run npm install -g
2) If everything runs correctly this will build and create node oracle modules at
C:\Users\[user]\AppData\Roaming\npm\node_modules
3) If you not defined yet , define an enviroment variable
NODE_PATH=C:\Users\[user]\AppData\Roaming\npm\node_modules
Run a sample testoracle.js
------------------------------------------------------------------
var oracle = require('oracle'); //without tns var connString = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=db)))"; var connectData = { "tns": connString, "user": "user", "password": "pwd" }; oracle.connect(connectData, function(err, connection) { if (err) { console.log("Error connecting to db:", err); return; } connection.execute("SELECT systimestamp FROM dual", [], function(err, results) { if (err) { console.log("Error executing query:", err); return; } console.log(results); connection.close(); // call only when query is finished executing }); });
------------------------------------------------------------------
If you get this error,
fs.js:438
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^
Error: ENOENT, no such file or directory 'C:\oracle\node-oracle-master\test\tests-settings.json'
while running your program, just make sure your path should have
C:\oracle\instantclient_12_1_64\sdk\lib\msvc\vc10;
C:\oracle\instantclient_12_1_64;
before C:\oracle\product\11.2.0\client_1\bin
ie your path should be like this
C:\oracle\instantclient_12_1_64\sdk\lib\msvc\vc10;C:\oracle\instantclient_12_1_64;C:\oracle\product\11.2.0\client_1\bin
Just Verified the same softwares/steps works on windows server 2008 r2
If you get this error,
fs.js:438
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^
Error: ENOENT, no such file or directory 'C:\oracle\node-oracle-master\test\tests-settings.json'
while running your program, just make sure your path should have
C:\oracle\instantclient_12_1_64\sdk\lib\msvc\vc10;
C:\oracle\instantclient_12_1_64;
before C:\oracle\product\11.2.0\client_1\bin
ie your path should be like this
C:\oracle\instantclient_12_1_64\sdk\lib\msvc\vc10;C:\oracle\instantclient_12_1_64;C:\oracle\product\11.2.0\client_1\bin
Just Verified the same softwares/steps works on windows server 2008 r2