-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Newbie can't get nhibernate to connect to mysql [SOLVED]
PostPosted: Fri Jun 30, 2006 3:52 pm 
Newbie

Joined: Fri Jun 30, 2006 3:44 pm
Posts: 4
Hi all,

I am new to nhibernate and am having trouble connecting to my mysql database. My config file looks like this:



Code:
<configSections>
       <section
         name="nhibernate"
         type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
       />
       <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
     </configSections>

   <nhibernate>
       <add
         key="hibernate.connection.provider_class"         
         value="NHibernate.Connection.DriverConnectionProvider"
       />
       <add
         key="hibernate.dialect"                     
         value="NHibernate.Dialect.MySQLDialect"
       />
       <add
         key="hibernate.connection.driver_class"         
         value="NHibernate.Driver.MySqlDataDriver"
       />
       <add
         key="hibernate.connection.connection_string"
         value="Server=localhost;user ID=WebUser;password=xxxx;Database=NewZealandRugbySong"
       />
     </nhibernate>


my code looks like this:

Code:
Configuration config = new Configuration();
config.AddClass(typeof(User));
            
log.Info("About to build session factory");
ISessionFactory factory = config.BuildSessionFactory();
log.Info("About to open session");
ISession session = factory.OpenSession();


And the log looks like this:

Code:
2006-06-30 20:41:22,129 [1080584544] INFO  NewZealandRugbySong.Register [(null)] - About to open session
2006-06-30 20:41:22,132 [1080584544] DEBUG NHibernate.Impl.SessionImpl [(null)] - opened session
2006-06-30 20:41:22,132 [1080584544] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - begin
2006-06-30 20:41:22,133 [1080584544] ERROR NewZealandRugbySong.Register [(null)] - Exception
NHibernate.ADOException: cannot open connection ---> System.InvalidOperationException: The user must provide an ADO.NET connection - NHibernate is not creating it.
in <0x00033> NHibernate.Connection.UserSuppliedConnectionProvider:GetConnection ()
in <0x00038> NHibernate.Impl.SessionFactoryImpl:OpenConnection ()--- End of inner exception stack trace ---

in <0x00086> NHibernate.Impl.SessionFactoryImpl:OpenConnection ()
in <0x0001f> NHibernate.Impl.SessionImpl:Connect ()
in <0x0003c> NHibernate.Impl.SessionImpl:get_Connection ()
in <0x000af> NHibernate.Transaction.AdoTransaction:Begin (IsolationLevel isolationLevel)


I have copied MySql.Data.dll Version=1.0.7.30072 to the bin directory. I have verified the connection string is correct by creating and opening a connection myself like so:

Code:
MySqlConnection conn = new MySqlConnection("Server=localhost;user ID=WebUser;password=12lduJFhE;Database=NewZealandRugbySong");
conn.Open();
log.Info("Connection opened!");


If anyone can help me out I'd really appreciate it!
Cheers,
Roboguy


Last edited by roboguy on Fri Jun 30, 2006 5:38 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 5:38 pm 
Newbie

Joined: Fri Jun 30, 2006 3:44 pm
Posts: 4
Hi all,

I was missing ICSharpCode.SharpZipLib.dll from my bin directory.

Hopefully this helps someone else avoid my pain!

Cheers,
Roboguy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.