使用 JavaScript 连接到 Oracle 数据库
我正在使用 Oracle 10g 后端。我使用 JavaScript 中的 oracle TNS 来连接 Oracle DB。当我在本地系统上运行该表单时,它显示正常,但当我在客户端系统上的 IIS 上运行它时,它显示 undefined
。请帮助我在客户端计算机上的 Google Chrome 中正确运行此程序。
我的代码如下:
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;
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.
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请不要这样做,假设它甚至有效,它非常危险,你将你的用户名和密码发送给客户端,让他们能够做任何他们想做的事情(假设这是客户端javascript,它我猜可能是服务器端)。
创建一个 Web 服务来提供您需要的服务并从 JS 调用该服务。
Please DONT do 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 ).
Create a web service to provide the services you need and call that from JS.
正如 @Matthew 所建议的,这是一个糟糕的想法,但可以使用 node-oracledb - Oracle 数据库的 Node.js 驱动程序。
请找到以下链接:
https://blogs. oracle.com/opal/post/introducing-node-oracledb-a-nodejs-driver-for-oracle-database
As @Matthew suggested, it is a terrible idea, but it's possible using node-oracledb - a Node.js driver for Oracle Database.
Kindly find the link below :
https://blogs.oracle.com/opal/post/introducing-node-oracledb-a-nodejs-driver-for-oracle-database