2 Replies Latest reply: Dec 5, 2010 8:11 AM by 413566 RSS

    Javascript Oracle Connection

    413566
      How to make a fuzzy architecture: direct connection from the IE browser to an Oracle database ( needs Oracle net installed on the client )

      Maybe this is helpful for someone...

      Save this in a html page and "run" it in IE:

      <HTML>
      <HEAD>
      <TITLE>Javascript Oracle Connection</TITLE>
      <SCRIPT>


      function testoracle(){
      var conObj = new ActiveXObject('ADODB.Connection');
      var connectionString = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=ora10;uid=scott;pwd=tiger;"
      //here ora10 is your Oracle alias
      conObj.Open(connectionString);
      var rs = new ActiveXObject("ADODB.Recordset");
      rs.Open("SELECT * FROM dual", conObj);
      while(!rs.eof)
           {       document.write(rs(0));
           document.write('<br>');
                rs.movenext;

           }
      rs.close;
      conObj.close;
      }


      </SCRIPT>
      </HEAD>
      <BODY onload="testoracle();">

      </BODY>
      </HTML>
        • 1. Re: Javascript Oracle Connection
          764844
          Very helpful information. Just want to add the connection that worked for me:

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
          <head>
          <title>Connecting to Oracle using JavaScript</title>
          </head>
          <body>
          <script language="JavaScript" type="text/javascript">
          <!--
          var conObj = new ActiveXObject('ADODB.Connection');

          var connectionString = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=your_ip_address)(PORT=your_port)))(CONNECT_DATA=(SID=your_sid)(SERVER=DEDICATED)));User Id=your_uid;Password=your_pwd;"

          conObj.Open(connectionString);
          var rs = new ActiveXObject("ADODB.Recordset");

          sql = "SELECT SYSDATE FROM DUAL"

          rs.Open(sql, conObj);

          alert(rs(0));

          rs.close;
          conObj.close;
          //-->
          </script>
          </body>
          </html>

          Hope this helps.
          Jhon Castro
          • 2. Re: Javascript Oracle Connection
            413566
            Nice it was helpful for at least one person, even after 6 years :-)