错误是这样的。
//////////////////////////
2004-11-16 15:06:44 net.sf.hibernate.cfg.Environment <clinit>信息: Hibernate 2.1.22004-11-16 15:06:45 net.sf.hibernate.cfg.Environment <clinit>信息: loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.microsoft.jdbc.sqlserver.SQLServerDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.cache.provider_class=net.sf.hibernate.cache.HashtableCacheProvider, hibernate.cache.use_query_cache=true, hibernate.max_fetch_depth=1, hibernate.dialect=net.sf.hibernate.dialect.SQLServerDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.jdbc.batch_size=0, hibernate.query.substitutions=true 1, false 0, yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=sa, hibernate.connection.url=jdbc:microsoft:sqlserver://SDTCNJAVA03:1433;DatabaseName=test;SelectMethod=cursor, hibernate.connection.password=java, hibernate.connection.pool_size=1}2004-11-16 15:06:45 net.sf.hibernate.cfg.Environment <clinit>信息: using java.io streams to persist binary types2004-11-16 15:06:45 net.sf.hibernate.cfg.Environment <clinit>信息: using CGLIB reflection optimizer2004-11-16 15:06:45 net.sf.hibernate.cfg.Configuration addClass信息: Mapping resource: hibernate2/Person.hbm.xml2004-11-16 15:06:46 net.sf.hibernate.cfg.Binder bindRootClass信息: Mapping class: hibernate2.Person -> Person2004-11-16 15:06:46 net.sf.hibernate.dialect.Dialect <init>信息: Using dialect: net.sf.hibernate.dialect.SQLServerDialect2004-11-16 15:06:46 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing one-to-many association mappings2004-11-16 15:06:46 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing one-to-one association property references2004-11-16 15:06:46 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing foreign key constraints2004-11-16 15:06:47 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing one-to-many association mappings2004-11-16 15:06:47 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing one-to-one association property references2004-11-16 15:06:47 net.sf.hibernate.cfg.Configuration secondPassCompile信息: processing foreign key constraints2004-11-16 15:06:47 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute信息: Running hbm2ddl schema export2004-11-16 15:06:47 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute信息: writing generated schema to file: sql.txt2004-11-16 15:06:47 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute信息: exporting generated schema to database2004-11-16 15:06:47 net.sf.hibernate.connection.DriverManagerConnectionProvider configure信息: Using Hibernate built-in connection pool (not for production use!)2004-11-16 15:06:47 net.sf.hibernate.connection.DriverManagerConnectionProvider configure信息: Hibernate connection pool size: 12004-11-16 15:06:47 net.sf.hibernate.connection.DriverManagerConnectionProvider configure信息: using driver: com.microsoft.jdbc.sqlserver.SQLServerDriver at URL: jdbc:microsoft:sqlserver://SDTCNJAVA03:1433;DatabaseName=test;SelectMethod=cursor2004-11-16 15:06:47 net.sf.hibernate.connection.DriverManagerConnectionProvider configure信息: connection properties: {user=sa, password=java}2004-11-16 15:06:50 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute严重: schema export unsuccessfuljava.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source) at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source) at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source) at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:140) at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:95) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:119) at net.sf.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:84) at hibernate2.Client1.main(Client1.java:24)

解决方案 »

  1.   

    Error establishing socket.
    那个连接字串对吗? 写个小程序用jdbc先连接试试看
      

  2.   

    请楼主把hibernate-cft.xml文件帖出来看看里面是否加载了刚才的Person.hbm.xml,我用的是ORACLE的数据库,贴出来给你看看
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
    <hibernate-configuration>
        <session-factory>
             <property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
            <!-- Mapping files -->
            <mapping resource="Person.hbm.xml"/>
        </session-factory></hibernate-configuration>请检查        <mapping resource="Person.hbm.xml"/> 你是否写了
      

  3.   

    你用"jdbc:odbc:数据源"的形式试一下,
      

  4.   

    用JavaWebStudio 2005的Hibernate文件向导,自动配置和自动生成所有文件,可减少出错机会:
    http://dev.csdn.net/develop/article/50/50737.shtm
    http://javawebstudio.51.net/J2005/j05_New_7.htm
      

  5.   

    用jsql驱动试试,http://www.hibernate.org.cn/3.html 有个做好的例子,自己对比一下!