Как исправить javax.net.ssl.SSLException - PullRequest
0 голосов
/ 18 октября 2019

Я пытаюсь подключиться к базе данных, используя MySQL Workbench в Java. Соединение должно быть между двумя компьютерами. Хост без базы данных имеет следующую строку для установления соединения: "jdbc: mysql: //192.168.43.26: 3306 / DATABASEE? User = admin & password = toor" 192.168.43.26 - фактический IP-адрес сервера;и DATABASEE имя базы данных.

public static int CheckLogin(String Username, String Psw) throws InterruptedException {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        // Create a variable for the connection string.
        String connectionUrl = "jdbc:mysql://192.168.43.26:3306/DATABASEE?user=admin&password=toor";

        try {Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement();
            ResultSet sr = stmt.executeQuery("select * from Users;");
            while(sr.next()) {
                String S = sr.getString("Username");
                String S2 = sr.getString("Psw");
                if(S.equals(Username) && S2.contentEquals(Psw)) {
                    con.close();
                    return 0;
                }
            }
            con.close();
        }
        // Handle any errors that may have occurred.
        catch (SQLException e) {
            e.printStackTrace();
        }
        return 1;
    }

После выполнения следующего кода Eclipse выдает мне следующие ошибки:

    Fri Oct 18 18:01:40 CEST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    Fri Oct 18 18:01:41 CEST 2019 WARN: Caught while disconnecting...

    EXCEPTION STACK TRACE:



    ** BEGIN NESTED EXCEPTION ** 

    javax.net.ssl.SSLException
    MESSAGE: closing inbound before receiving peer's close_notify

    STACKTRACE:

        javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
            at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
            at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
            at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
            at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
            at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
            at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
            at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
            at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:2246)
            at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4236)
            at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1462)
            at Ciao.OpenSQL.CheckLogin(OpenSQL.java:132)
            at Ciao.MasterStart.actionPerformed(MasterStart.java:160)
            at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
            at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
            at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
            at 

java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
        at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
        at java.desktop/java.awt.Component.processMouseEvent(Component.java:6632)
        at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
        at java.desktop/java.awt.Component.processEvent(Component.java:6397)
        at java.desktop/java.awt.Container.processEvent(Container.java:2263)
        at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5008)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
        at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
        at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
        at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
        at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
        at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
        at java.desktop/java.awt.Component.dispatchEvent(Component.java:4840)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
        at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)


** END NESTED EXCEPTION **
...