oracledb_npm包的使用
oracledb_npm包的使用
文章目錄
- oracledb_npm包的使用
- 1.使用需求
- 2.開發(fā)環(huán)境
- 3.環(huán)境搭建
- 4.示例程序測試
- 4.1 下載示例程序
- 4.2 修改數(shù)據(jù)庫連接配置
- 4.3 運行
- 5.參考鏈接
- 6. 資源下載
1.使用需求
通過Node.js搭建服務(wù)端應(yīng)用,直接操作oracle數(shù)據(jù)庫,實現(xiàn)數(shù)據(jù)庫的連接以及增刪改查等操作。
2.開發(fā)環(huán)境
- Windows 10
- Oracle服務(wù)端11g
- Oracle客戶端instantclient-basic-windows.x64-12.1.0.2.0
- Node.js v14.2.0-x64
- oracledb V4.2.0
- Visual Studio 2010 Redistributable
3.環(huán)境搭建
參考鏈接:https://oracle.github.io/node-oracledb/INSTALL.html#instwin
- 安裝Node.js,默認安裝即可;
- 在某一文件夾下(以Node_OracleDB為例),使用npm init初始化項目;
- 通過命令npm install oracledb --save,安裝oracledb包;
- 下載并配置免安裝版的oracle客戶端,**注意:**要和Node.js架構(gòu)匹配,目前安裝的node.js為64位,因此要配置64位oracl客戶端,另外注意要選擇與oracle服務(wù)端版本匹配的客戶端版本;
In summary, Oracle Client 19, 18 and 12.2 can connect to Oracle Database 11.2 or greater. Oracle Client 12.1 can connect to Oracle Database 10.2 or greater. Oracle Client 11.2 can connect to Oracle Database 9.2 or greater. The technical restrictions on creating connections may be more flexible. For example Oracle Client 12.2 can successfully connect to Oracle Database 10.2.
針對Oracle服務(wù)端11g下載的是instantclient-basic-windows.x64-12.1.0.2.0,之后配置環(huán)境變量,在path環(huán)境變量中添加客戶端文件路徑,注意放到path的最前面。
- 根據(jù)Oracle客戶端版本選擇合適的Visual Studio Redistributables進行安裝
4.示例程序測試
4.1 下載示例程序
到https://github.com/oracle/node-oracledb克隆整個項目,將其中的examples文件夾拷貝至環(huán)境搭建時的Node_OracleDB文件夾下
4.2 修改數(shù)據(jù)庫連接配置
在examples文件夾下有dbconfig.js文件,修改其中的用戶名、密碼、連接字符串等配置
4.3 運行
執(zhí)行命令node .\examples\example.js,看到控制臺輸出下面數(shù)據(jù)說明數(shù)據(jù)庫操作成功。
5.參考鏈接
6. 資源下載
代碼文件已上傳到: https://download.csdn.net/download/wml00000/12464941
總結(jié)
以上是生活随笔為你收集整理的oracledb_npm包的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sessionStorage细节
- 下一篇: js中两次按位取反