0
votes

I'm trying to connect my application with an Oracle database using NHIBERNATE 3.1.0.4000 version and I got this error:

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

I've already tried some connection strings and none of them work:

  • SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MySID)));uid=MyUser;pwd=MyPassword;

  • Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MySID)));User Id=MyUser;Password=MyPassword;

  • SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SID=MySID)));uid=MyUser;pwd=MyPassword;

  • Driver={Microsoft ODBC for Oracle};Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SID=MySID)));Uid=MyUser;Pwd=MyPassword;

The properties I have are User, Password, Host, Port and SID. In other words, there is no TNS. My options is to connect directly.

Some informations may are important:

  • I'm running it using a test project.
  • I'm using VPN connection to database server.
  • I can connect to the server via TOAD Client fine
  • My project was built with .NET framework 3.5
  • The oracle version is 9i

Installed binaries files:

  • Castle.Core
  • Iesi.Collection
  • Nhibernate
  • Nhibernate.ByteCode.Castle
  • Oracle.DataAcess

Development enviroment is:

  • Windows 7 64 bits
  • Visual Studio 2010 Premium

hibernate.hbm.xml file content:

  <?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory name="NHibernate.Test">
        <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
        <property name="connection.connection_string">
      SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SID=MySID)));uid=MyUser;pwd=MyPassword;
    </property>
        <property name="show_sql">false</property>
        <property name="dialect">NHibernate.Dialect.Oracle9iDialect</property>
        <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    </session-factory>
</hibernate-configuration>

Thank you all is advanced! I hope so much be helped!

2

2 Answers

2
votes
  • Confirm wether you have a SID or a SERVICE_NAME (What are you using in TOAD?) and pick the appropriate connection string.
  • Check that the name matches the listener exactly.
  • If the server is in a domain, add the domain to the SID/SERVICE_NAME: MySID.MY.DOMAIN.COM
  • If you're already doing that, try removing it.
0
votes

Finally I solved this problem.

Besides the binaries files that I wrote before, I just added the System.Data.OracleClient reference to repository's and test's project and it magically worked!

However, Is important to say that is extremely important move the Visual Studio to a folder without parenthesis, because it was drive me for another error. When you install it in a 64 bits platform, the Visual Studio is installed inside "C:\ProgramFiles(86x)\" folder, and it is a problem for the Oracle Instant Client.