1
votes

My problem is the following:

I have a Oracle in a 32 bits ubuntu server 12.04 LTS, but I created another database for migrate to a Windows 2008 R2 64 bits. I succesfully installed the oracle and copy all the data I have. The problem came when I had to change the connections of one of my .NET projects from use the first one to the second one, where I got a "ORA-12154: TNS:could not resolve the connect identifier specified" error. I used the 32 bit ODAC dlls downloaded from Oracle.

TNSNAMES:

A_LINUX =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

B_LINUX =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

C_LINUX =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

D_DBLILLY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

E_DBLILLY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.y)(PORT = 1523))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl2)
    )
  )

A_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

B_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

C_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

D_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

E_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

TEST_WINDOWS =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.z)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.c.local)
    )
  )

_WINDOWS are the windows one and _LINUX the linux. With this tnsnames I can connect only to linux. The ips are correct, the port and the names too. ODAC is installed in C:\OracleODAC\x32 and i added to PATH the directory. I added the bin directory too. Also, ORACLE_HOME and ORACLE_SID are correctly set.

Any tip? Thanks in advance.

EDIT: I can connect using the same home with TOAD. I can connect my project to LINUX but not to WINDOWS, with x86/x64 compiled version.

EDIT2: <add name="PRD" connectionString="Data Source=D_WINDOWS;User ID=****;Password=****;" providerName="Oracle.DataAccess.Client" />

3

3 Answers

1
votes

I would test the oracle client in a databas-adm-program first. I use Toad which I configure to use the same oracle client as my .net applications. If it works there you can rule out that the TNS is the problem and just focus on the 32 vs 64bit problem in your .net application. PS: I know that this fits bettre as a comment but i couldnt comment becasue im a n00b here

1
votes

It looks like you have simple TNS resolution error to me. You might have multiple oracle homes and are not realizing it, so you are missing a second tns names file. IMO the easiest way to force a tns names file is with the TNS_ADMIN environment variable. You can also embed the TNS string in place of the alias directly in the connection string. If you are using the managed client, tns alias can be defined in the config file itself. All of these are demonstrated in this other answer:

https://stackoverflow.com/a/31592492/852208

-2
votes

Since the database is 64bits, I think the ODAC should be 64bits too. Have a look to this page to get the good one: [http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html]

Then, I suppose a listener is correctly started???

And in your tnsnames, you may have to suffix the connect identifier: TEST_ASTREA.cartif.local = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.109.103)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl.cartif.local) ) )

Hope that helps...

Christian