这是 hibernate.cgf.xml的配置文件:
com.mysql.jdbc.Driver
jdbc:mysql://127.0.0.1:3306/test02
root
654321
org.hibernate.dialect.MySQLDialect
false
这是运行后的错误代码:
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Environment
信息: Hibernate 3.2.0
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Environment
信息: hibernate.properties not found
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Environment buildBytecodeProvider
信息: Bytecode provider name : cglib
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Environment
信息: using JDK 1.4 java.sql.Timestamp handling
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Configuration configure
信息: configuring from resource: /hibernate.cfg.xml
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Configuration getConfigurationInputStream
信息: Configuration resource: /hibernate.cfg.xml
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Configuration addResource
信息: Reading mappings from resource: pojo/User.hbm.xml
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: pojo.User -> tb_users
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Configuration addResource
信息: Reading mappings from resource: pojo/Customer.hbm.xml
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: pojo.Customer -> tb_customer_info
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.Configuration addResource
信息: Reading mappings from resource: pojo/Communication.hbm.xml
九月 17, 2018 9:46:10 下午 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
信息: Mapping class: pojo.Communication -> tb_communication_info
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.Configuration doConfigure
信息: Configured SessionFactory: null
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.HbmBinder bindCollectionSecondPass
信息: Mapping collection: pojo.Customer.communicationList -> tb_communication_info
九月 17, 2018 9:46:11 下午 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: Using Hibernate built-in connection pool (not for production use!)
九月 17, 2018 9:46:11 下午 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: Hibernate connection pool size: 20
九月 17, 2018 9:46:11 下午 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: autocommit mode: false
九月 17, 2018 9:46:11 下午 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://127.0.0.1:3306/test02
九月 17, 2018 9:46:11 下午 org.hibernate.connection.DriverManagerConnectionProvider configure
信息: connection properties: {user=root, password=****}
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
警告: Could not obtain connection metadata
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:958)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2326)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at com.mr.contact.hibernate.HibernateInitialize.(HibernateInitialize.java:20)
at com.mr.contact.dao.DAOimpl.selectAllUser(DAOimpl.java:191)
at frame.MainFrame.(MainFrame.java:25)
at frame.MainFrame.main(MainFrame.java:32)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2999)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1885)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1814)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1207)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2249)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2280)
... 20 more
九月 17, 2018 9:46:11 下午 org.hibernate.dialect.Dialect
信息: Using dialect: org.hibernate.dialect.MySQLDialect
九月 17, 2018 9:46:11 下午 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
信息: Using default transaction strategy (direct JDBC transactions)
九月 17, 2018 9:46:11 下午 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
信息: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Automatic flush during beforeCompletion(): disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Automatic session close at end of transaction: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Scrollable result sets: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: JDBC3 getGeneratedKeys(): disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Connection release mode: auto
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Maximum outer join fetch depth: 2
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Default batch fetch size: 1
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Generate SQL with comments: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Order SQL updates by primary key: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
信息: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
九月 17, 2018 9:46:11 下午 org.hibernate.hql.ast.ASTQueryTranslatorFactory
信息: Using ASTQueryTranslatorFactory
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Query language substitutions: {}
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: JPA-QL strict compliance: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Second-level cache: enabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Query cache: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory createCacheProvider
信息: Cache provider: org.hibernate.cache.NoCacheProvider
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Optimize cache for minimal puts: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Structured second-level cache entries: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Statistics: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Deleted entity synthetic identifier rollback: disabled
九月 17, 2018 9:46:11 下午 org.hibernate.cfg.SettingsFactory buildSettings
信息: Default entity-mode: pojo
九月 17, 2018 9:46:11 下午 org.hibernate.impl.SessionFactoryImpl
信息: building session factory
九月 17, 2018 9:46:11 下午 org.hibernate.impl.SessionFactoryObjectFactory addInstance
信息: Not binding factory to JNDI, no JNDI name configured
九月 17, 2018 9:46:11 下午 org.hibernate.util.JDBCExceptionReporter logExceptions
警告: SQL Error: 0, SQLState: 08001
九月 17, 2018 9:46:11 下午 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: Could not create connection to database server.
Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1560)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.mr.contact.dao.DAOimpl.selectAllUser(DAOimpl.java:194)
at frame.MainFrame.(MainFrame.java:25)
at frame.MainFrame.main(MainFrame.java:32)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.Util.getInstance(Util.java:383)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:958)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2326)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:794)
at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:400)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
... 16 more
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2999)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1885)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1814)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1207)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2249)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2280)
... 30 more