开发者

Java MYSQL Connection hangs in Windows 7, Works on Mac

开发者 https://www.devze.com 2023-01-06 14:16 出处:网络
The same programs work on the Mac but does not seem to work on Windows. I have tried using both hibernate and a regular mysql.connection but both seem to hang.

The same programs work on the Mac but does not seem to work on Windows. I have tried using both hibernate and a regular mysql.connection but both seem to hang.

My firewalls are all off and I have no problem connecting to the database through 3rd party programs like sqlyog or even through the HQL query generator in netbeans. But when it is compiled, connecting to the database seems to hang for about 5 minutes and then prints out the following error.

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


When I cut & pasted your error into Google it brought back this. Try it with the standard port 3306 if you're not using it and see if that improves things.

I cut & pasted your error into Google and got this link back:

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

Don't know if it is identical to your situation. I'd recommend that practice in the future. I'll be faster than waiting 6-8 weeks for an answer here.

0

精彩评论

暂无评论...
验证码 换一张
取 消