########################################
Customer.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-mapping> 
<class name="hibernate3.Customer" table="Customer"  proxy="Customer"> <id name="id" column="id"> 
<generator class="increment"/> 
</id> <property name="username" column="username" /> 
<property name="password" column="password" /> </class> 
</hibernate-mapping>中的
<property name="username" column="username" /> 
<property name="password" column="password" /> 
改成
<property name="username">
   <column name="username"/>
</property>
        
<property name="password">
    <column name="password"/>
</property>试一下

解决方案 »

  1.   

    你的Customer.hbm.xml的dtd验证给错了,改成下面的
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >映射文件应该用hibernate-mapping-3.0.dtd
      

  2.   

    myth822(枫红一刀) 说得对,但我改正后还不能连到ms sqlserver数据库,出错信息如下:
     WARN SettingsFactory:103 - Could not obtain connection metadata
    java.sql.SQLException: Network error IOException: Connection refused: connect
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:371)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
    ......
    org.hibernate.exception.JDBCConnectionException: Cannot open connection
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:66)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    ....
    Caused by: java.sql.SQLException: Network error IOException: Connection refused: connect
    ....
    Caused by: java.net.ConnectException: Connection refused: connect
    到底哪里有错?还请各位帮忙!
      

  3.   

    <property name="hibernate.connection.url">
    jdbc:jtds:sqlserver://localhost:1433/yufan;
    </property><property name="hibernate.connection.driver_class">
    net.sourceforge.jtds.jdbc.Driver
    </property>改成
    <property name="hibernate.connection.url">
    jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=yufan
    </property><property name="hibernate.connection.driver_class">
    com.microsoft.jdbc.sqlserver.SQLServerDriver
    </property>试试,我这里没有mssql,不能试呀
      

  4.   

    弱弱的问一下myth822(枫红一刀)是不是大连的?fts了解?
      

  5.   

    你可以先用hibernate工具联一下,例如middlegen
      

  6.   

    to: myth822(枫红一刀):有没有hibernate 连mssql的实例,发给我一个。
    e-mail:  [email protected]
      

  7.   

    我现改用reverocean(不懂)的方法,数据库可连上了,但有以下信息是什么意思??ERROR BasicLazyInitializer:104 - CGLIB Enhancement failed: hibernate3.Customer
    java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:95)
    at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
    at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory
    .....
    WARN PojoEntityTuplizer:167 - could not create proxy factory for:hibernate3.Customer
    org.hibernate.HibernateException: CGLIB Enhancement failed: hibernate3.Customer
    at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:106)
    at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate
    .....
    avax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)请各位指导!
      

  8.   

    因为hibernate一个重要的特性:延迟加载需要通过cglib来代理,所以需要引入cglib.jar包
      

  9.   

    如何引入cglib.jar包?? 且怎么用这个包?
      

  10.   

    myth822(枫红一刀) ^_^,他乡遇故知呀。王兆林?嘿嘿,知道我是谁不?我也是从fts出来的。
      

  11.   

    如何引入cglib.jar包?? 且怎么用这个包?
    将这个包加入倒你测classpath就行了
      

  12.   

    我的msn  [email protected]