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