这是我存放各类文件的目录:
d:\workspace\My1stHibernate\lib\db\msbase.jar
d:\workspace\My1stHibernate\lib\db\mssqlserver.jar
d:\workspace\My1stHibernate\lib\db\msutil.jar
d:\workspace\My1stHibernate\lib\hibernate\这里存放了hibernate3.0.jar和hibernate包下的lib目录中的各文件
d:\workspace\My1stHibernate\classes\Test.java和Test.class(这里有main函数,运行时就执行它)
d:\workspace\My1stHibernate\classes\Customer.java和Customer.class
d:\workspace\My1stHibernate\classes\Customer.hbm.xml
d:\workspace\My1stHibernate\classes\hibernate.cfg.xml
这是我的hibernate.cfg.xml内容<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory name="java:/hibernate/HibernateFactory">
<property name="show_sql">true</property>
<property name="connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver 
</property>
<property name="connection.url">
jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=hibernate_test;SelectMethod=cursor 
</property>
<property name="connection.username">
sa
</property>
<property name="connection.password">
wsnedy
</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect</property>
<mapping resource="Customer.hbm.xml"/>
</session-factory>
</hibernate-configuration>

解决方案 »

  1.   

    msbase.jar、mssqlserver.jar、msutil.jar这三个包应该放到
    d:\test\lib下,然后在改clsspath值为classpath=d:\workspace\My1stHibernate\lib\msbase.jar;d:\workspace\My1stHibernate\lib\mssqlserver.jar;;d:\workspace\My1stHibernate\lib\msutil.jar
    试试看吧
      

  2.   

    无非是一个
    classpath的问题了,把你jar包所在目录加到classpath里面就可以了
      

  3.   


    d:\workspace\My1stHibernate\lib\db\msbase.jar
    d:\workspace\My1stHibernate\lib\db\mssqlserver.jar
    d:\workspace\My1stHibernate\lib\db\msutil.jar改为
    d:\workspace\My1stHibernate\lib\msbase.jar
    d:\workspace\My1stHibernate\lib\mssqlserver.jar
    d:\workspace\My1stHibernate\lib\msutil.jar试试
      

  4.   

    设置的没有错啊,重建一个web项目,再试试
      

  5.   

    我没有建web服务,我只是写了一个,application应用(唉,你们说的我都试了还是不行,不知道是不是hibernate3有问题)
    import org.hibernate.*;
    import org.hibernate.cfg.*;public class Test 
    {
    public static void main(String[] args) 
       {
    try 
    {
    SessionFactory sf = new Configuration().configure().buildSessionFactory();
    Session session = sf.openSession();
    Transaction tx = session.beginTransaction();
    for (int i = 0; i <200; i++) 
    {
    Customer customer = new Customer();
    customer.setUsername("customer" + i);
    customer.setPassword("customer");
    session.save(customer);
    }
    tx.commit();
    session.close();
    }
    catch (HibernateException e)
    {
    e.printStackTrace();
    }
       }
    }
      

  6.   

    upup....我也遇到同样的问题了我想做个c/s的。。但是也找不到driver。我用的是mysql