Adeel Aslam
Adeel Aslam

Reputation: 1294

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;

Upvotes: 1

Views: 55543

Answers (2)

Anupam
Anupam

Reputation: 517

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

Upvotes: 0

Matthew Watson
Matthew Watson

Reputation: 14233

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.

Upvotes: 28

Related Questions