简体   繁体   中英

SSLException error in Eclipse with Hibernate, how do I fix this?

I'm trying to put values in a MySQL database using Hibernate but I get this error:

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

I have tried many things; Restarting my pc did (as expected) not work. Reinstalled MySQL (both server and workbench) twice, once with only deleting data files, second time with removing everything related to MySQL. SSL is turned off in the MySQL server, yet there are SSL certificates. I checked nothing about SSL while reinstalling MySQL. The teacher also tried many things and fiddled with it for almost an hour.

Don't exactly know what code to show but this is what I have in my AppStarter:

public class AppStarter {

public static void main(String[] args) {

    DAOFactory.setTheFactory(DAOFactories.HIBERNATE.getTheFactory());

    Speler a = new Player();
    Speler b = new Player();
    Speler c = new Player();

    a.setNaam("Test 1");
    b.setNaam("Test 2");
    c.setNaam("Test 3");


    DAOFactory.getTheFactory().getSpelerDAO().saveOrUpdate(a);
    DAOFactory.getTheFactory().getSpelerDAO().saveOrUpdate(b);
    DAOFactory.getTheFactory().getSpelerDAO().saveOrUpdate(c);

    HibernateSessionManager.shutdown();

    // TODO Auto-generated method stub

}

}

It's supposed to work fine and and I should be able to put values into my database. Feel free to ask if more information is necessary.

EDIT: added useSSL=false to my hibernate.connection.url, this resolved the issue.

An SSLException can be sometimes thrown while destroying the session if the connection was closed abnormally. It's probably because the remote peer is closing the connection immediately not sending the last close_notify. And also it seems a JDK bug https://bugs.openjdk.java.net/browse/JDK-8199440?attachmentOrder=desc .

Try this:Set db_url = "jdbc:mysql://localhost:3306/Avvappa?useSSL=false", the Avvappa is localhost database name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM