1
votes

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.

Any suggestions will be helpful.

1
Are you sure that your SID is actually 'dbname'? - Drumbeg
I can connect to Oracle using SQL Developer using the host machine running linux with the same information. I can ping it too via the Windows VM where the automated testing application lives. I cleaned up the connection string details to not use the actual ones because it has customer name etc. - user3063502

1 Answers

0
votes

Major issue was a mismatch between Application arch and Drivers arch. Following was done on a fresh vm from scratch:

  1. Application and driver architecture needs to match, i.e. both 32bit or 64 bit.
  2. Control Panel -> Administrative Tools -> ODBC Sources on Win 7 amd64 will show 64bit available drivers.
  3. To check what 32bit is installed, run -> cmd -> c:\Windows\SysWow64\odbcad32.exe.

If you end up defining a User/System DSN for Oracle_Ora11gHome1 driver (wtf Oracle), TNS Service Name is yourip:port/sid