0

I'm using NHibernate with a web application and Oracle 10g XE, and I'm currently getting the following error:

ORA-06413: Connection not open.

My guess is it's a problem with my connection string. Here's my Hibernate configuration in Web.config:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory name="MyProject.MyAssembly">
      <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
      <property name="connection.connection_string">Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)));User ID=myid;Password=mypassword</property>
      <property name="show_sql">true</property>
      <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
      <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <mapping assembly="Domain" />
    </session-factory>
</hibernate-configuration>

I've also tried using the following connection string:

<property name="connection.connection_string">
  User ID=myid;Password=mypassword;Data Source=localhost
</property>

That resulted in the following error:

ORA-12154: TNS:could not resolve the connect identifier specified.

Could anyone provide any insight into what I might be doing wrong here?

Edit

I created a console application project inside the same solution. I created a hibernate.cfg.xml file with the same settings and added it to that project. I can persist objects with no problems.

I've switched my database from Oracle 10g to MySQL and it works fine in the web application. Why does Oracle 10g only work in the console application and not in the web application?

4
  • look at this: dba-oracle.com/t_ora_06413_connection_not_open.htm Commented Jan 9, 2011 at 22:31
  • @Falcon: I did searching on this error prior to posting here, but it was my understanding that the "invalid path" bug (Bug 3807408 I believe) caused by parentheses was addressed in later releases. Commented Jan 9, 2011 at 22:37
  • What about the file extension? Commented Jan 9, 2011 at 22:52
  • That as well. The reason I'm skeptical is because I've used virtually this same setup with a different, non-web application, and did not have any connection issues. The difference there was I had a hibernate.cfg.xml file instead of having the Hibernate configuration in a Web.config file like I have now. However, I tried using a separate hibernate.cfg.xml file and got the same error. Commented Jan 9, 2011 at 23:05

2 Answers 2

1

Apparently Oracle 10g is a bit finicky on 64-bit systems. The best option seemed to be switching to MySQL.

Sign up to request clarification or add additional context in comments.

Comments

0

I faced this error today and found interesting thing. I tried to use XE client oracle.dataaccecc.dll as reference and before the statement

 sessionFactory = new NHibernate.Cfg.Configuration().Configure(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NHibernate\\Oracle.cfg.xml")).BuildSessionFactory();
            

i entered these lines:

OracleConnection conn = new OracleConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connString"].ConnectionString);
            conn.Open();
conn.Close();

And everything started to work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.