Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How can I connect to Oracle by JavaScript Step.

  1. #1
    Join Date
    Mar 2009
    Posts
    1

    Post How can I connect to Oracle by JavaScript Step.

    Hi,

    I tried to connect to Oracle via JavaScript Step.
    My script is as follow:

    var strConnString = "Provider=OraOLEDB.Oracle;Data Source=SISSAMPLE;User ID=samples;Password=samples;PLSQLRset=1"
    var conn = new ActiveXObject("ADODB.Connection");
    conn.open(strConnString);
    var rs = conn.execute("SELECT * FROM SISTEST");
    var rsNum = rs.fields.count;
    rs.close();
    conn.close();

    But there is an error when I run the transformation:

    2009/03/26 14:58:32 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : Unexpected error :
    2009/03/26 14:58:32 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : org.pentaho.di.core.exception.KettleValueException:
    2009/03/26 14:58:32 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : Javascript error:
    2009/03/26 14:58:32 - Modified Java Script Value.0 - ERROR (version 3.1.0, build 826 from 2008/09/30 11:32:36) : ReferenceError: "ActiveXObject" is not defined. (script#11)


    Any samples about connecting to DB using JavaScript? And Any user guide about JavaScript internal API objects like _step_?

    And I have another question about this.
    Is there any reserved words in "rs.fi(i).name + ":" + rs.fields(i).value"?

    Thanks very much!

    Juan Wang

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    "ActiveXObject" will not work ... the javascript step uses the mozilla engine. There's something like fireToDB() that you can use, but it requires some care.

    Some more information at http://wiki.pentaho.com/display/EAI/...a+Script+Value

    Regards,
    Sven

  3. #3
    Join Date
    Nov 1999
    Posts
    9,729

    Thumbs down

    Let's just hope these things get done because of some weird proof of concept (or anything like that) and not for an actual corporation or <gasp> customer.

  4. #4
    Join Date
    Oct 2015
    Posts
    1

    Default

    This code worked for me, as I am connecting to database, It must call the current time and date of your computer if you did your connection well,..
    but make sure to change the SID, IP address, username and password to suit yours. Thank you and I hope it works


    <!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=10.20.37.22)(PORT=1521)))(CONNECT_DATA=(SID=orcl)(SERVER=DEDICATED)));User Id=system;Password=manager1;"

    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>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.