初学ssh框架,看别人的配置都说可以,为什么我的就会报错,烦请各位指点一下:报错信息如下:2012-9-5 1:52:37 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2012-9-5 1:52:37 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.1}
2012-9-5 1:52:37 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2012-9-5 1:52:37 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2012-9-5 1:52:37 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2012-9-5 1:52:37 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2012-9-5 1:52:37 org.hibernate.internal.util.xml.XMLHelper$ErrorLogger error
ERROR: HHH000197: Error parsing XML: /hibernate.cfg.xml(6) Element type "session-factorty" must be declared.
2012-9-5 1:52:37 org.hibernate.internal.util.xml.XMLHelper$ErrorLogger error
ERROR: HHH000197: Error parsing XML: /hibernate.cfg.xml(20) The content of element type "hibernate-configuration" must match "(session-factory,security?)".
Exception in thread "main" org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2008)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1925)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1904)
at hibernate_test.test.main(test.java:14)
Caused by: org.xml.sax.SAXParseException: Element type "session-factorty" must be declared.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2005)
... 3 morehibernate.cfg.xml文件<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"><hibernate-configuration>
    <session-factorty>
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>    
        <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=sshdb</property>
        <property name="hibernate.connection.name">sshuser</property>
        <property name="hibernate.connection.password">123456</property>
         
<property name="hibernate.show_sql">true</property>               <property name="eclipse.connection.profile">SqlDriver</property>
        <mapping resource="hibernate_helloworld/hbhelloworld/po/User.hbm.xml"/>
    </session-factorty>
</hibernate-configuration>

解决方案 »

  1.   

    at hibernate_test.test.main(test.java:14)你的test代码也贴出来吧.
      

  2.   

    test的代码:
    package hibernate_test;import hbhelloworld.po.User;import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;public class test { public static void main(String[] args) {
    Configuration cfg=new Configuration() ;
    cfg=cfg.configure() ;

    @SuppressWarnings("deprecation")
    SessionFactory factory=cfg.buildSessionFactory() ;

    Session session=factory.openSession() ;
    Transaction tx=session.beginTransaction() ;

    User user=new User() ;
    user.setName("test01") ;
    user.setPassword("123456") ;
    session.save(user) ;
    tx.commit() ;
    session.close();

    }}
      

  3.   

     <property name="eclipse.connection.profile">SqlDriver</property>这句去掉
      

  4.   

    去掉了,现在报这个错:
    2012-9-5 17:03:25 org.hibernate.annotations.common.Version <clinit>
    INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
    2012-9-5 17:03:25 org.hibernate.Version logVersion
    INFO: HHH000412: Hibernate Core {4.1.6.Final}
    2012-9-5 17:03:25 org.hibernate.cfg.Environment <clinit>
    INFO: HHH000206: hibernate.properties not found
    2012-9-5 17:03:25 org.hibernate.cfg.Environment buildBytecodeProvider
    INFO: HHH000021: Bytecode provider name : javassist
    2012-9-5 17:03:25 org.hibernate.cfg.Configuration configure
    INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
    2012-9-5 17:03:25 org.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
    2012-9-5 17:03:25 org.hibernate.cfg.Configuration addResource
    INFO: HHH000221: Reading mappings from resource: hbhelloworld/po/user.hbm.xml
    2012-9-5 17:03:25 org.hibernate.cfg.Configuration doConfigure
    INFO: HHH000041: Configured SessionFactory: null
    2012-9-5 17:03:25 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
    2012-9-5 17:03:25 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000115: Hibernate connection pool size: 20
    2012-9-5 17:03:25 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000006: Autocommit mode: false
    2012-9-5 17:03:25 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000401: using driver [com.microsoft.jdbc.sqlserver.SQLServerDriver] at URL [jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sshdb]
    2012-9-5 17:03:25 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
    INFO: HHH000046: Connection properties: {name=sa, password=****}
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
    WARN: HHH000342: Could not obtain connection to query metadata : [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    2012-9-5 17:03:26 org.hibernate.dialect.Dialect <init>
    INFO: HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
    INFO: HHH000422: Disabling contextual LOB creation as connection was null
    2012-9-5 17:03:26 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
    INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
    2012-9-5 17:03:26 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
    INFO: HHH000397: Using ASTQueryTranslatorFactory
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
    WARN: SQL Error: 18452, SQLState: HY000
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
    ERROR: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
    WARN: SQL Error: 0, SQLState: 08001
    2012-9-5 17:03:26 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
    ERROR: [Microsoft][SQLServer 2000 Driver for JDBC]An error occured while attempting to log onto the database.
    Exception in thread "main" org.hibernate.exception.GenericJDBCException: Could not open connection
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
    at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:160)
    at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1396)
    at hbhelloworld.po.test.main(test.java:18)
    Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
    at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(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(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:193)
    at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:281)
    at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
    ... 5 more
      

  5.   

    终于搞定了,谢谢大家的参与,后面证实是mssql本身的包和hibernate有点问题,换成了jtds就可以了,好开心^_^
      

  6.   

    请问你的这个日志输出,使用什么方式控制的.
    log4j.properties如何配制才能控制Hibernate4的日志输出.
      

  7.   

    在eclipse里面有个控制台的,在那里运行时的报错信息