This post is similar to other connection problems with MySQL in this forum, but none of the solutions to these problems work for me.
The config.BuildSessionFactory() method is returning a factory with the ConnectionProvider set as UserSuppliedConnectionProvider, but this should be DriverConnectionProvider (the config.Properties shows DriverConnectionProvider correctly specified).
Obviously this is not correct, and when trying to create a session, the session.Connection throws an exception of type 'NHibernate.ADOException'
The inner exceptions boil down to "The user must provide an ADO.NET connection - NHibernate is not creating it."
I have been led to believe that the UserSuppliedConnectionProvider is a fallback if the DriverConnectionProvider fails - the question is, why is it failing? MySQL.Data.dll is referenced in the project, and is present in the output directory, as is ICSharpCode.SharpZipLib.
Anyone have any ideas?
Hibernate version:
NHibernate ver 1.2
Mapping documents:
hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">
<session-factory>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
<property name="connection.provider_class">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">Server=localhost;Database=theBombShack;User ID=bomber;Password=trhp,btrzE3Mx4bh</property>
</session-factory>
</hibernate-configuration>
Example mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
assembly="TheBombShack.SpecialOps"
namespace="TheBombShack.SpecialOps"
default-lazy="false">
<class name="clsAircraftModel" table="AircraftModel">
<id name="AircraftModelID" unsaved-value="0">
<generator class="native" />
</id>
<property name="Designation" length="100" />
<property name="Manufacturer" length="100"/>
<property name="MaximumSpeed"/>
<bag name="Parts" table="modelparts" inverse="true">
<key column="AircraftModelID"/>
<many-to-many class="clsPart" column="PartID" />
</bag>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:This happens when trying to read from the database, but I am aware that it is not a direct symptom of this error.
Code:
at NHibernate.Impl.SessionFactoryImpl.OpenConnection()
at NHibernate.Impl.SessionImpl.Connect()
at NHibernate.Impl.SessionImpl.get_Connection()
at NHibernate.Impl.BatcherImpl.Prepare(IDbCommand cmd)
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
at NHibernate.Impl.CriteriaImpl.List[T]()
at TheBombShack.Remote.clsNHibernateManager.getAll[T]() in D:\Documents\NMIT Stuff\BIT3\SDV300\Assignment\TheBombShack\TheBombShack.Remote\clsNHibernateManager.cs:line 107
Name and version of the database you are using:
MySQL ver 5.0