1

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;
4
  • 4
    I'd be very surprised if JavaScript running on a web site can start a ADODB connection with the default security settings. I hope that not even sites in the Intranet area can do this. Commented Oct 20, 2011 at 7:36
  • I never tried to do a DB connection in a client javascript, but you prolly don't have the the rights to do this action. Better do the connection and data stuff in a server sided page and deliver the results to the client which you can perform in your script then. Commented Oct 20, 2011 at 7:38
  • i agree with u but can u give any example to do this? Commented Oct 20, 2011 at 7:40
  • 1
    this looks IE only - Chrome won't support ActiveXObject Commented Oct 20, 2011 at 7:59

2 Answers 2

28

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Can u please give me an example to do this its urgent plz
That is a pretty big topic, and pretty much beyond the scope of stackoverflow. This isn't really the sort of thing I'd recommend doing urgently.
"giving them the ability to do anything they want" - But that's exactly what I want to do!
-1: I'm just wading through REST, SOAP and other middleman nonsense, where JDBC-style direct connection to database would have been simple and clean solution. What you are saying, one machine (javascript in browser sandbox) running general purpose programming language can't connect to the other (RDBMS server), or this connection is fundamentally unreliable?
0

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

1 Comment

I'd say that is problematic. Using the native driver for tests doesn't make them very portable. I agree with the sentiment of putting a 3rd party service in place to broker the test verifications.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.