Java MYSQL连接在Windows 7中运行,适用于Mac

时间:2010-07-06 01:03:36

标签: java mysql hibernate jdbc

相同的程序在Mac上运行,但似乎不适用于Windows。 我尝试过使用hibernate和常规的mysql.connection,但两者似乎都挂了。

我的防火墙全部关闭,通过第三方程序(如sqlyog)甚至通过netbeans中的HQL查询生成器连接到数据库都没有问题。但是在编译时,连接到数据库似乎会挂起大约5分钟,然后打印出以下错误。

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure    
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
            at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
            at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343)
            at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2308)
            at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2122)
            at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:774)
            at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
            at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
            at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:375)
            at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:289)
            at java.sql.DriverManager.getConnection(DriverManager.java:582)
            at java.sql.DriverManager.getConnection(DriverManager.java:154)
            at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
            at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
            at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
            at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
            at checkin.HibernateUtil.<clinit>(HibernateUtil.java:24)
            at checkin.CheckInTools.executeHQLQuery(CheckInTools.java:29)
            at checkin.CheckInTools.checkPassword(CheckInTools.java:43)
            at checkin.CheckInView$4.run(CheckInView.java:114)
            at java.lang.Thread.run(Thread.java:619) Caused by: java.net.SocketException: Malformed reply from SOCKS server
            at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:90)
            at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:429)
            at java.net.Socket.connect(Socket.java:529)
            at java.net.Socket.connect(Socket.java:478)
            at java.net.Socket.<init>(Socket.java:375)
            at java.net.Socket.<init>(Socket.java:218)
            at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:256)
            at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292)
            ... 23 more 06/07/2010 12:58:15 AM org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.MySQLDialect 06/07/2010 12:58:15 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) 06/07/2010 12:58:15 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Scrollable result sets: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC3 getGeneratedKeys(): disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Connection release mode: auto 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Maximum outer join fetch depth: 2 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Default batch fetch size: 1 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Generate SQL with comments: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL updates by primary key: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL inserts for batching: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 06/07/2010 12:58:15 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> INFO: Using ASTQueryTranslatorFactory 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: JPA-QL strict compliance: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Second-level cache: enabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory createCacheProvider INFO: Cache provider: org.hibernate.cache.NoCacheProvider 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Structured second-level cache entries: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Statistics: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Deleted entity synthetic identifier rollback: disabled 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Default entity-mode: pojo 06/07/2010 12:58:15 AM org.hibernate.cfg.SettingsFactory buildSettings INFO: Named query checking : enabled 06/07/2010 12:58:15 AM org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 06/07/2010 12:58:17 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured

1 个答案:

答案 0 :(得分:0)

当我切割&amp;将您的错误粘贴到Google中,然后将其带回this。如果您没有使用标准端口3306,请尝试使用它,看看是否可以改善这一点。

我切割&amp;将您的错误粘贴到Google并重新获得此链接:

http://bugs.mysql.com/bug.php?id=47494

不知道它是否与您的情况相同。我建议将来练习。我会比等待6-8周的答案快得多。