简体   繁体   English

调用Driver#connect时出错,并且无法创建与数据库服务器的连接

[英]Error calling Driver#connect and Could not create connection to database server

Mar 05, 2019 10:12:28 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
 Mar 05, 2019 10:38:45 AM  <clinit>
INFO: HHH000206: hibernate.properties not found
//hibernate class
public class HibernateUtil {
    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure().buildSessionFactory();
        }
        catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

}

java.lang.ExceptionInInitializerError java.lang.ExceptionInInitializerError

Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect 引起原因:org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. 引起原因:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法创建与数据库服务器的连接。 Attempted reconnect 3 times. 尝试重新连接3次。 Giving up. 放弃。

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.password">***</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/foot?autoReconnect=true&amp;=utf-8&amp;useUnicode=true&amp;connectionCollation=utf8_unicode_ci&amp;characterSetResults=utf8</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="hbm2ddl.auto">update </property>

    <mapping class="vn.myclass.core.persistence.entity.MemberEntity" />
    <mapping class="vn.myclass.core.persistence.entity.RoleEntity" />
    <mapping class="vn.myclass.core.persistence.entity.ProductEntity" />
    <mapping class="vn.myclass.core.persistence.entity.CommentEntity" />
</session-factory>
</hibernate-configuration>

我修复了位于驱动程序连接器中的问题,因为mysql版本8.0支持驱动程序连接器/ j 5.5及更高版本

暂无
暂无

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

相关问题 使用 Hibernate 调用 Driver#connect 时出错 - “Error calling Driver#connect” using Hibernate Hibernate、JDBC:调用 Driver#connect 时出错 - Hibernate, JDBC: Error calling Driver#connect 无法创建sessionFactory object.org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - Failed to create sessionFactory object.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect amazon aws ubuntu java mysql webservice“错误调用Driver#connect” - amazon aws ubuntu java mysql webservice “Error calling Driver#connect” 引起原因:org.hibernate.exception.JDBCConnectionException:调用Driver#connect时出错 - Caused by: org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect failed.org.hibernate.exception.JDBCConnectionException:使用PostGres Hibernate调用Driver#connect时出错 - failed.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect with PostGres Hibernate Problem connect Android Studio-MySQL using JDBC (Error: java.sql.SQLNonTransientConnectionException: Could not create connection to database server.) - Problem connect Android Studio-MySQL using JDBC (Error : java.sql.SQLNonTransientConnectionException: Could not create connection to database server.) 无法建立与数据库服务器的连接-Eclipse MySQL错误 - Could not create connection to database server - Eclipse MySQL error “无法创建与数据库服务器的连接” netbeans谷歌云sql错误 - “Could not create connection to database server” netbeans google cloud sql error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM