使用 JavaScript 连接到 Oracle DB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7832538/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:45:55  来源:igfitidea点击:

Connecting to Oracle DB with JavaScript

javascriptoracle

提问by Adeel Aslam

I am using an Oracle 10g backend. I use the oracle TNS in JavaScript to connect with the Oracle DB. When I run the form on my local system then it displays fine, but when I run it on IIS on a client system it displays undefined. Please help me run this correctly on client machine in Google Chrome.

我正在使用 Oracle 10g 后端。我使用 JavaScript 中的 oracle TNS 与 Oracle DB 连接。当我在本地系统上运行该表单时,它显示正常,但是当我在客户端系统上的 IIS 上运行它时,它显示undefined. 请帮我在谷歌浏览器的客户端机器上正确运行它。

My Code is Below:

我的代码如下:

 var conObj = new ActiveXObject('ADODB.Connection');
    var conString = "Provider=OraOLEDB.Oracle; Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=202.125.144.34)(PORT=1521)))(CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)));User Id=admin; Password=admin;"
    conObj.Open(conString);
    var rs =  new ActiveXObject("ADODB.Recordset");
    sql = "SELECT * from info"
    rs.open(sql,conString);
    var rsnum=rs.fields.count;
    alert(rsnum);
    rs.close;
    conObj.close;

回答by Matthew Watson

Please DONTdo this, assuming it even works, its horribly dangerous, you are shipping your username and password to the client, giving them the ability to do anything they want ( assuming this is client side javascript, it could be server side I guess ).

DONT做到这一点,假设它甚至工程,它的可怕的危险,要运送您的用户名和密码给客户,使他们能够呼风唤雨的能力(假设这是客户端的JavaScript,也可能是服务器端我猜) .

Create a web service to provide the services you need and call that from JS.

创建一个 Web 服务来提供您需要的服务并从 JS 中调用它。

回答by Anupam

As @Matthew suggested, it is a terrible idea, but it's possible using node-oracledb - a Node.js driver for Oracle Database.

正如@Matthew 建议的那样,这是一个糟糕的主意,但可以使用 node-oracledb - Oracle 数据库的 Node.js 驱动程序。

Kindly find the link below : https://blogs.oracle.com/opal/entry/introducing_node_oracledb_a_node

请找到以下链接:https: //blogs.oracle.com/opal/entry/introducing_node_oracledb_a_node