本帖最后由 luoning1217 于 2012-11-13 14:50:29 编辑

解决方案 »

  1.   

    楼主你的配置出了问题,这个链接的写法有点怪异<property name = "hibernate.connection.url ">jdbc:sqlserver://localhost:1841;DatabaseName=Hibernate</property>
    改成下面这个试试:yourDatabaseName就是你链接数据的名字,你数据库名称是Hibernate?
    还有用户名密码是sa吗?确认一下吧<property name = "hibernate.connection.url ">jdbc:sqlserver://localhost:1841:yourDatabaseName</property>
      

  2.   

    不对楼主,楼上的回答有点不太对。sql2005是像你这么配置的。
    你的配置是对的,报这个错可能是没有读取到配置文件。
    import com.test.util.HibernateUtil;这个HibernateUtil是楼主自己写的吗?hibernate4和3读取配置文件是不同的,建议楼主自己写。或者看下面的简单的读取配置文件的代码。hibernate.cfg.xml文件位于src跟目录下面。 Configuration config = new Configuration();
     config.configure();
     serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
     sessionFactory = config.buildSessionFactory(serviceRegistry);
     Session session = sessionFactory.getCurrentSession();
    如果上面的代买还是报错,在配置文件中增加一行配置:<property name="javax.persistence.validation.mode">none</property>
    如果上面的代码还是报错,那