试图创建数据库模式-没有可用的数据库提供程序,无法创建连接
||
我从Northwind spring.net/NHibernate示例开始。我试图获取现有示例以生成模式。我将CustomerEditController web.xml条目更改为
<object name=\"CustomerEditController\" type=\"NHibernateCustomerEditController\" scope=\"session\">
<constructor-arg name=\"sessionFactory\" ref=\"NHibernateSessionFactory\"/>
<constructor-arg name=\"local\" ref=\"&NHibernateSessionFactory\"/>
</object>`
将ѭ1更改为以下内容:
public class NHibernateCustomerEditController : ICustomerEditController
{
private readonly ISessionFactory sessionFactory;
private readonly LocalSessionFactoryObject LocalsessionFactory;
private Customer currentCustomer;
public NHibernateCustomerEditController(ISessionFactory sessionFactory, LocalSessionFactoryObject local)
{
this.sessionFactory = sessionFactory;
this.LocalsessionFactory = local;
}
private ISession Session
{
get { return sessionFactory.GetCurrentSession(); }
}
public void EditCustomer(Customer customer)
{
currentCustomer = customer;
}
public void Clear()
{
currentCustomer = null;
}
public Customer CurrentCustomer
{
get
{
Customer customer = currentCustomer;
//since the Customer entity may have been retrieved from a prior request, we need to reattach it to the current session
// in order to support lazy-loading, etc. on the Customer
Session.Lock(customer, LockMode.None);
return customer;
}
}
public void MakeANewDatabase() {
SchemaExport schema = new SchemaExport(LocalsessionFactory.Configuration);
schema.Create(true, true);
}
}
我在“客户列表”页面上添加了一个按钮,该按钮会转到MakeANewDatabase
方法。
当我按下按钮时,我收到错误“ 4”。看起来当创建SchemaExport
时,DBProvider
为空。
完整的错误文字:
An exception of type \'System.Exception\' occurred in Spring.Data.NHibernate30.DLL but was not handled in user code
Additional information: There was no DB provider available, unable to create connection
An exception of type \'NHibernate.HibernateException\' occurred in NHibernate.DLL but was not handled in user code
Additional information: There was no DB provider available, unable to create connection
没有找到相关结果
已邀请:
1 个回复
攫怂绵十