休眠 - 无法连接到数据库 [英] Hibernate - Cannot connect to DB
本文介绍了休眠 - 无法连接到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用mysql,所以包括mysql.jdbc,这些都是我的hibernate设置。
I try to use mysql so include mysql.jdbc and these are my hibernate settings.
<?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>
但是当我尝试connecto db时,我得到这个错误:
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)
我甚至不使用derby为什么我得到这个错误?
I dont even use derby why i get this error?
推荐答案
您没有在任何地方指定连接驱动程序。它告诉你它正在尝试使用 apache.org.derby.jdbc.ClientDriver
进行连接。
You are not specifying the connection driver anywhere. It is telling you it's trying to connect using apache.org.derby.jdbc.ClientDriver
.
以下列方式指定MySQL驱动程序:
Specify the MySQL driver, in the following way:
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
这篇关于休眠 - 无法连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文