curiouswebster
asked on
NHibernate: "cannot open connection"
On the line of code below which says FAILS HERE I get an exception.
"cannot open connection"
I assume I have a configuration problem with the hibernate.cfg.xml file but can not find the problem since the exception is being thrown by NHibernate. Any idea where to look?
at NHibernate.Impl.SessionFac toryImpl.O penConnect ion()
at NHibernate.Impl.Connection Manager.Co nnect()
at NHibernate.Impl.Connection Manager.Ge tConnectio n()
at NHibernate.Impl.BatcherImp l.Prepare( IDbCommand cmd)
at NHibernate.Impl.BatcherImp l.ExecuteR eader(IDbC ommand cmd)
at NHibernate.Loader.Loader.G etResultSe t(IDbComma nd st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.D oQuery(ISe ssionImple mentor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.D oQueryAndI nitializeN onLazyColl ections(IS essionImpl ementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.D oList(ISes sionImplem entor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.L istIgnoreQ ueryCache( ISessionIm plementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.L ist(ISessi onImplemen tor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Hql.Classic.Que ryTranslat or.List(IS essionImpl ementor session, QueryParameters queryParameters)
at NHibernate.Impl.SessionImp l.Find(Str ing query, QueryParameters parameters, IList results)
at NHibernate.Impl.SessionImp l.Find[T]( String query, QueryParameters parameters)
at NHibernate.Impl.QueryImpl. List[T]()
at PizzaPilot.Server.Runtime. Impl.Serve rObjectSto reImpl.Get AllDeviceR ecords() in C:\Documents and Settings\Administrator\Des ktop\Code\ PPServer\r eleases\DD Server_Ame ricanaPhas e1\PizzaPi lotRuntime \PizzaPilo t\Server\R untime\Imp l\ServerOb jectStoreI mpl.cs:lin e 328
at MobileService.InitializeCo mponent() in c:\Documents and Settings\Administrator\Des ktop\Code\ PPServer\r eleases\DD Server_Ame ricanaPhas e1\Central izedMobile Service\Ap p_Code\Mob ileService .cs:line 43
"cannot open connection"
I assume I have a configuration problem with the hibernate.cfg.xml file but can not find the problem since the exception is being thrown by NHibernate. Any idea where to look?
at NHibernate.Impl.SessionFac
at NHibernate.Impl.Connection
at NHibernate.Impl.Connection
at NHibernate.Impl.BatcherImp
at NHibernate.Impl.BatcherImp
at NHibernate.Loader.Loader.G
at NHibernate.Loader.Loader.D
at NHibernate.Loader.Loader.D
at NHibernate.Loader.Loader.D
at NHibernate.Loader.Loader.L
at NHibernate.Loader.Loader.L
at NHibernate.Hql.Classic.Que
at NHibernate.Impl.SessionImp
at NHibernate.Impl.SessionImp
at NHibernate.Impl.QueryImpl.
at PizzaPilot.Server.Runtime.
at MobileService.InitializeCo
public IList<DeviceIDRecord> GetAllDeviceRecords()
{
ISessionFactory factory = nhibConfig.BuildSessionFactory();
ISession session = factory.OpenSession();
String q = "from DeviceIDRecord as rec where rec.UID is not null";
IQuery query = session.CreateQuery(q);
IList<DeviceIDRecord> evtList = query.List<DeviceIDRecord>(); <<<<<< FAILS HERE
return evtList;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What database are you using? And let me see your connection string as well.
ASKER
I am using SQL Express 2005.
<property name="connection.connectio n_string"> Server=loc alhost\SQL EXPRESS;in itial catalog=PPDB01;User Id=sa;Password=sqlserversa password;< /property>
Is there a way to verify this connection string is actually being use by NHibernate?
<property name="connection.connectio
Is there a way to verify this connection string is actually being use by NHibernate?
ASKER
Thanks.
ASKER