如何修复此错误:无法与选定的Hibernate配置文件建立数据库连接。请验证数据库.......... rnate.cfg.xml

时间:2014-02-17 10:54:12

标签: sql-server hibernate

我尝试创建一个Hibernate项目,但我遇到了一个问题:

  

<property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:jtds:sqlserver://localhost:1433/DemoHibernate</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.show_sql">true</property>

这是我的hibernate.cfg.xml.In,我使用的是jtds库:         DemoHibernate:我在sql server 2005中的数据库         sa:我在sql server 2005中的用户名         root:我的密码 当我右键单击 - &gt; New-&gt; Other-&gt; Hibernate-&gt; Hibernate Reverse Engineering Wizard出现.Follow错误:

无法与选定的Hibernate配置文件建立数据库连接。请在hibernate.cfg.xml中验证数据库连接详细信息

我认为来自jtds库的原因是因为如果我使用hibernate.cfg.xml的内容如下:

<?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.DerbyDialect</property>
    <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
    <property name="hibernate.connection.url">jdbc:derby://localhost:1527/sample</property>
    <property name="hibernate.connection.username">app</property>
    <property name="hibernate.connection.password">app</property>
  </session-factory>
</hibernate-configuration>

=&GT;一切都很好

有谁可以帮助我?

0 个答案:

没有答案