1

I am new to erlang, sorry I might be missing something very small. I am trying the following code for a DB handler to oracle in Erlang, in red-hat.

#!/usr/bin/env escript
-module(test).
-compile(export_all).

-define(CONNECT_OPTIONS,[
                {auto_commit, on},
                {scrollable_cursors, off},
                {trace_driver, on}
            ]).
-define(CONNECT_STRING,"DSN=oracle10g;DBQ=*******;UID=********;PWD=********").

main(_)->
    odbc:start(),
    {ok, ConnObj} = odbc:connect(?CONNECT_STRING,?CONNECT_OPTIONS),
        io:format(ConnObj).

I have the unix odbc and oracle thin-client installed, the respective DSN is also declared in the /etc/odbc.ini file and also ~/.odbc.ini file .

but I run in to the following error :

escript: exception error: no match of right hand side value {error, "[unixODBC][Driver Manager]Data source name not found, and no default driver specified SQLSTATE IS: 00000 Connection to database failed."}

Can someone please explain how to establish a connection handler to oracle DB in erlang.

Thanks in advance.

Jnana
  • 61
  • 5

1 Answers1

0

I would suggest you to check the following two files:

/etc/odbc.ini

and

/etc/odbcinst.ini

I was getting a similar error, but correcting these values solved my problem:

Data in my odbc.ini:

[REQUIRED_SID]

Driver=SOME_DRIVER_NAME

Description=

Trace=

Server=

PORT=

Database=

Userid=

Password=

and in odbcinst.ini

Description=

[SOME_DRIVER_NAME]

Driver=

Add values as required.

richa_v
  • 119
  • 1
  • 7