'Connect to Oracle DB from JavaScript

I am using a proprietary automated testing product that uses a javascript engine to run test scripts.

I am trying to connect to Oracle DB on a server to setup test data/environment. My code uses the following connection string:

var dbDriverString = 'Driver={Microsoft ODBC for Oracle};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.1)(PORT=1521))(CONNECT_DATA=(SID=dbname)));Uid=abc;Pwd=abc;';

var connectionString = dbDriverString;
    
if (Database.DoAttach(connectionString, '') == true)
    Tester.Assert('Connected to database.', true);

I installed Oracle Database 11g Release 2 Client (11.2.0.1.0) for Microsoft Windows (x64) client on my Windows VM. I am unable to connect to the database. I keep getting the following error:

[Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle failed on SQL_HANDLE_ENV failed.

I have setup all paths correctly. ORACLE_HOME is set, ORACLE_HOME/bin is also set as environment variable. I have also tried to use other drivers/connection strings.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source