簡體   English   中英

休眠-無法連接到數據庫

[英]Hibernate - Cannot connect to DB

我嘗試使用mysql,所以包括mysql.jdbc,這些是我的休眠設置。

<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
      <session-factory>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/TekirMobile</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.connection.password">fenderpass</property>
        <property name="hibernate.show_sql">true</property>
        <property name="hibernate.current_session_context_class">thread</property>
        <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
      </session-factory>
    </hibernate-configuration>

但是當我嘗試連接數據庫時,出現此錯誤:

Unable to connect: Cannot establish a connection jdbc:mysql://localhost:3306/mydbname using apache.org.derby.jdbc.ClientDriver(Unable to find a suitable driver)

我什至不使用德比,為什么會出現此錯誤?

您沒有在任何地方指定連接驅動程序。 它告訴您它正在嘗試使用apache.org.derby.jdbc.ClientDriver進行連接。

通過以下方式指定MySQL驅動程序:

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM