简体   繁体   中英

Connecting to Oracle DB with JavaScript

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;

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.

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/entry/introducing_node_oracledb_a_node

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM