简体   繁体   English

带有Hibernate的Eclipse中的SSLException错误,如何解决此问题?

[英]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: 我正在尝试使用Hibernate将值放入MySQL数据库中,但出现此错误:

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. 重新安装了MySQL两次(服务器和工作台),一次仅删除数据文件,第二次删除了与MySQL相关的所有内容。 SSL is turned off in the MySQL server, yet there are SSL certificates. MySQL服务器中已关闭SSL,但仍有SSL证书。 I checked nothing about SSL while reinstalling MySQL. 重新安装MySQL时,我未对SSL进行任何检查。 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: 不完全知道要显示什么代码,但这是我在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. 编辑:添加useSSL = false到我的hibernate.connection.url,这解决了问题。

An SSLException can be sometimes thrown while destroying the session if the connection was closed abnormally. 如果连接异常关闭,则在销毁会话时有时会抛出SSLException。 It's probably because the remote peer is closing the connection immediately not sending the last close_notify. 可能是因为远程对等方立即关闭了连接,但没有发送最后一个close_notify。 And also it seems a JDK bug https://bugs.openjdk.java.net/browse/JDK-8199440?attachmentOrder=desc . 而且似乎还有一个JDK错误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 试试这个:设置db_url =“ jdbc:mysql:// localhost:3306 / Avvappa?useSSL = false”,Avvappa是本地主机数据库名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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