Lassi Autio
Lassi Autio

Reputation: 1239

Connecting Oracle with unixODBC: TNS:net service name is incorrectly specified

I am trying to connect from Ubuntu to Oracle in Windows Server. I have installed unixODBC and Oracle driver to Ubuntu. When I try to connect using isql it gives following error:

user@user:~$ isql -v oracle-jono username password
[S1000][unixODBC][Oracle][ODBC][Ora]ORA-12545: Connect failed because target host or object does not exist
[ISQL]ERROR: Could not SQLConnect

And when I run it with sudo I get different error:

[S1000][unixODBC][Oracle][ODBC][Ora]ORA-12162: TNS:net service name is incorrectly specified

I have tried many combinations of enviranment variables without success (ORACLE_HOME, ORACLE_SID, TNS_ADMIN, TWO_TASK). This is my very first time I am doing anything with Oracle so practically I don't know anything about it. I have also tried to modify odbc.ini and tnsnames.ora files.

My odbc.ini for this Oracle connection:

[oracle-jono]
Description = ...
Driver      = OracleDriver
Server      = 111.222.111.222
User        = ...
Password    = ...
Port        = 1521
Database    = mydatabase

My tnsnames.ora:

Data Source=
    (DESCRIPTION=
        (ADDRESS_LIST=
            (ADDRESS=
                (PROTOCOL=TCP)
                (HOST=111.222.111.222)
                (PORT=1521)
            )
        )
        (CONNECT_DATA=
            (SERVER=DEDICATED)
            (SERVICE_NAME=mydatabase)
        )
);User Id=...;Password=...;

Is there something clearly wrong? What should I put to environment variables? Do I have to do something in Windows Server where Oracle database exits (for example Oracle listeners)?

Upvotes: 2

Views: 7017

Answers (1)

Lassi Autio
Lassi Autio

Reputation: 1239

I tried many many things and not sure which of them worked but my guess is that ServerName in odbc.ini fixed this error:

[oracle-jono]
Description = ...
...same as above...
ServerName  = //111.222.111.222:1521/mydatabase

Upvotes: 10

Related Questions