mercredi 2 janvier 2019

Can not read response from server. Expected to read 4,739,923 bytes, read 17 bytes before connection was unexpectedly lost

The following error message occurred when I used Eclipse to connect Mysql in the cloud server So far, this problem has not been solved. I don't know why this happened. Using Navicat, MySQL can be connected.

 

    ** BEGIN NESTED EXCEPTION ** 

    com.mysql.jdbc.CommunicationsException
    MESSAGE: Communications link failure due to underlying exception: 

    ** BEGIN NESTED EXCEPTION ** 

    java.io.EOFException
    MESSAGE: Can not read response from server. Expected to read 4,739,923 bytes, read 17 bytes before connection was unexpectedly lost.

    STACKTRACE:

    java.io.EOFException: Can not read response from server. Expected to read 4,739,923 bytes, read 17 bytes before connection was unexpectedly lost.
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1997)
        at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:611)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1044)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
        at com.mysql.jdbc.Connection.(Connection.java:1555)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.minlu.basedao.BaseDao.(BaseDao.java:33)
        at com.minlu.basedao.MainCalss.main(MainCalss.java:5)


    ** END NESTED EXCEPTION **



    Last packet sent to the server was 0 ms ago.

    STACKTRACE:

    com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

    ** BEGIN NESTED EXCEPTION ** 

    java.io.EOFException
    MESSAGE: Can not read response from server. Expected to read 4,739,923 bytes, read 17 bytes before connection was unexpectedly lost.

    STACKTRACE:

    java.io.EOFException: Can not read response from server. Expected to read 4,739,923 bytes, read 17 bytes before connection was unexpectedly lost.
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1997)
        at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:611)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1044)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
        at com.mysql.jdbc.Connection.(Connection.java:1555)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.minlu.basedao.BaseDao.(BaseDao.java:33)
        at com.minlu.basedao.MainCalss.main(MainCalss.java:5)


    ** END NESTED EXCEPTION **



    Last packet sent to the server was 0 ms ago.
        at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:641)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1044)
        at com.mysql.jdbc.Connection.createNewIO(Connection.java:2775)
        at com.mysql.jdbc.Connection.(Connection.java:1555)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.minlu.basedao.BaseDao.(BaseDao.java:33)
        at com.minlu.basedao.MainCalss.main(MainCalss.java:5)


    ** END NESTED EXCEPTION **

 

Is the "user name" the current library name or the'root'name? Is'PASSWORD'the current library password or'root' password here?

  

    package com.minlu.basedao;

    import java.io.IOException;
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.util.Properties;

    public class BaseDao {
        private static String USER = "minlu_****"; 

        private static String PASSWORD = "*******3aFCDi";//自己创建数据库所设置的密码 

        private String MYSQL_URL="jdbc:mysql://47.244.***.***:**/minlu_****"; 

        private static Connection conn = null; 

        PreparedStatement pre = null;// 预编译对象 

        public Connection getConn() { 
            return conn; 
        } 

        public static void setConn(Connection conn) { 
            BaseDao.conn = conn; 
        } 

        public BaseDao() 
        { 

            try { 
                Class.forName("com.mysql.jdbc.Driver");//加载驱动 
                System.out.println("加载驱动成功");
            } catch (ClassNotFoundException e) { 
                // TODO Auto-generated catch block 
                System.out.println("找不到驱动程序类 ,加载驱动失败!"); 
            }

            try { 
                conn = DriverManager.getConnection(MYSQL_URL, USER, PASSWORD);//创建数据库链接对象 
                System.out.println("数据库链接成功2");
            } catch (SQLException es) { 
                // TODO Auto-generated catch block 
                System.out.println("数据库连接失败!!!"+es.getMessage()); 
            } 
        } 
    }

  



Aucun commentaire:

Enregistrer un commentaire