hibernate exception

杨松坤 发布于 2012/11/14 23:47
阅读 3K+
收藏 0

2011-11-14 23:40:38 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2011-11-14 23:40:38 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.7.Final}
2011-11-14 23:40:38 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2011-11-14 23:40:38 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2011-11-14 23:40:38 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2011-11-14 23:40:38 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2011-11-14 23:40:39 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2011-11-14 23:40:39 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: User.hbm.xml
2011-11-14 23:40:39 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2011-11-14 23:40:39 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
2011-11-14 23:40:40 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000038: Composite-id class does not override equals(): User
2011-11-14 23:40:40 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000039: Composite-id class does not override hashCode(): User
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [org.hibernate.dialect.MySQLDialect] at URL [jdbc:mysql://localhost/cs]
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}
2011-11-14 23:40:40 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:mysql://localhost/cs
2011-11-14 23:40:40 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2011-11-14 23:40:40 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
2011-11-14 23:40:40 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2011-11-14 23:40:40 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
hibernate ok!!
2011-11-14 23:40:45 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 08001
2011-11-14 23:40:45 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: No suitable driver found for jdbc:mysql://localhost/cs
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Could not open connection
 at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131)
 at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
 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:1392)
 at ysk.main(ysk.java:18)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/cs
 at java.sql.DriverManager.getConnection(DriverManager.java:602)
 at java.sql.DriverManager.getConnection(DriverManager.java:154)
 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
2011-11-14 23:40:38 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2011-11-14 23:40:38 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.7.Final}
2011-11-14 23:40:38 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2011-11-14 23:40:38 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2011-11-14 23:40:38 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
2011-11-14 23:40:38 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
2011-11-14 23:40:39 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2011-11-14 23:40:39 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: User.hbm.xml
2011-11-14 23:40:39 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
2011-11-14 23:40:39 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
2011-11-14 23:40:40 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000038: Composite-id class does not override equals(): User
2011-11-14 23:40:40 org.hibernate.mapping.RootClass checkCompositeIdentifier
WARN: HHH000039: Composite-id class does not override hashCode(): User
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [org.hibernate.dialect.MySQLDialect] at URL [jdbc:mysql://localhost/cs]
2011-11-14 23:40:40 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}
2011-11-14 23:40:40 org.hibernate.engine.jdbc.internal.JdbcServicesImpl configure
WARN: HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:mysql://localhost/cs
2011-11-14 23:40:40 org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2011-11-14 23:40:40 org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000422: Disabling contextual LOB creation as connection was null
2011-11-14 23:40:40 org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
2011-11-14 23:40:40 org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
hibernate ok!!
2011-11-14 23:40:45 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: 08001
2011-11-14 23:40:45 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: No suitable driver found for jdbc:mysql://localhost/cs
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Could not open connection
 at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131)
 at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
 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:1392)
 at ysk.main(ysk.java:18)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/cs
 at java.sql.DriverManager.getConnection(DriverManager.java:602)
 at java.sql.DriverManager.getConnection(DriverManager.java:154)
 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

 

hibernate.cfg.xml

 

 

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
 "-//Hibernate/Hibernate Configuration DTD//EN"
 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>

<session-factory>
 <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
 <property name="connection.driver_class">
  org.hibernate.dialect.MySQLDialect
 </property>
 <property name="connection.username">root</property>
 <property name="connection.password"></property>
 <property name="connection.url">jdbc:mysql://localhost/cs</property>
 <property name="show_sql">true</property>
 <mapping resource="User.hbm.xml" />
</session-factory>
</hibernate-configuration>

 

 

user.hbm.xml

 

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
   
<hibernate-mapping>
<!--
    Created by the Middlegen Hibernate plugin 2.1

    http://boss.bekk.no/boss/middlegen/
    http://www.hibernate.org/
-->

<class
    name="User"
    table="user"
    schema="cs"
>

    <composite-id>
        <key-property
            name="id"
            column="id"
            type="java.lang.Long"
            length="20"
        />
        <key-property
            name="name"
            column="name"
            type="java.lang.String"
            length="1"
        />
    </composite-id>   


    <!-- Associations -->
    <!-- derived association(s) for compound key -->
    <!-- end of derived association(s) -->
 

</class>
</hibernate-mapping>

 

 

 

 

 

 

加载中
0
陶邦仁
陶邦仁

改成:

 http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd

No suitable driver found for jdbc:mysql://localhost/cs,然后在看下mysql驱动包是否引入Project了。

 

返回顶部
顶部