简体   繁体   English

休眠-无法连接到数据库

[英]Hibernate - Cannot connect to DB

I try to use mysql so include mysql.jdbc and these are my hibernate settings. 我尝试使用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>

but when i try to connecto db i get this error: 但是当我尝试连接数据库时,出现此错误:

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

I dont even use derby why i get this error? 我什至不使用德比,为什么会出现此错误?

You are not specifying the connection driver anywhere. 您没有在任何地方指定连接驱动程序。 It is telling you it's trying to connect using apache.org.derby.jdbc.ClientDriver . 它告诉您它正在尝试使用apache.org.derby.jdbc.ClientDriver进行连接。

Specify the MySQL driver, in the following way: 通过以下方式指定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