Forum Stats

  • 3,826,750 Users
  • 2,260,703 Discussions
  • 7,897,071 Comments

Discussions

Javascript Oracle Connection

413566
413566 Member Posts: 31
edited Dec 5, 2010 9:11AM in APEX Discussions
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>
29000552727565

Comments

  • 764844
    764844 Member Posts: 6
    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
  • 413566
    413566 Member Posts: 31
    Nice it was helpful for at least one person, even after 6 years :-)
    29000552727565
This discussion has been closed.