node 串連oracle

來源:互聯網
上載者:User

標籤:

使用node 串連oracle對於剛開始入手 node項目或之前使用mysql 的同學,需要花一點時間對環境進行安裝。

鏡像

npm: https://www.npmjs.com/package/oracle

taobao: https://npm.taobao.org/package/oracle 

注意:在taobao 鏡像上面有一句醒目的描述 “This library is not maintained. Oracle has made there own driver.” ,所以我這裡用的是 npm的鏡像。

安裝oralce 之前需要配置一些環境,上面兩個鏡像有描述,具體的可以參考:https://github.com/xianglongxiang/node-oracledb,下面是我安裝的一個步驟:

 

一、安裝工具

1、安裝Python 2.7 : https://www.python.org/download/releases/2.7/

安裝成功:

2、安裝GCC、Visual Studio 或者 similar,我這裡安裝的是Visual Studio:

Visual Studio: https://www.visualstudio.com/

安裝成功:

3.安裝oracle 的個用戶端和SDK

用戶端和SDK:http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html

如果你沒有帳號,可以在這裡下載 

用戶端:http://pan.baidu.com/s/1nuOg9QT

SDK:http://pan.baidu.com/s/1eRERzBs

將instantclient_basic-windows.x64-12.1.0.2.0.zip 和 instantclient_sdk-windows.x64-12.1.0.2.0.zip 解壓到“同一個目錄檔案夾下”,特別注意,同一個目錄檔案夾下面。

將檔案夾地址配置到環境變數: C:\oracle\instantclient.

如果上面的工具安裝,沒有問題進行下面一步操作

二、安裝node,這裡不詳解,具體的看node 官網, https://nodejs.org/en/ 

三、通過Visual Studio 配置

開啟Visual Studio ->工具->NuGet包管理器->程式包管理主控台  輸入下面命令

set OCI_LIB_DIR=C:\oracle\instantclient\sdk\lib\msvc
set OCI_INC_DIR=C:\oracle\instantclient\sdk\include

 

四、安裝npm 安裝oracle 驅動

使用cmd或編輯器的控制台 npm install  oralcedb --save

如果這裡能安裝成功,說明orace驅動已經完成好了。

 

五、測試是否串連成功

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("串連成功")

});

  

 



 

node 串連oracle

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.