当前位置: 首页 > 知识库问答 >
问题:

HIbernate工具org.HIbernate.exception.jdbcConnectionException:调用驱动程序#Connect时出错

唐弘和
2023-03-14

我的hibernate.cfg.xml如下:

<hibernate-configuration>
 <session-factory name="TestSessionFactory">
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">!QAZ2wsx</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://localhost;databaseName=Testing</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
 </session-factory>
</hibernate-configuration>

在Hibernate Configurations选项卡中,我选择会话工厂,然后错误如下:

共有1个答案

宇文勇
2023-03-14

好的,最后找到,使用的端口是65064,而不是默认的1433。因此,正确的hibernate.cfg.xml应该如下所示:

<hibernate-configuration>
 <session-factory name="TestSessionFactory">
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">!QAZ2wsx</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://localhost:65064;databaseName=Testing</property>
  <property name="hibernate.connection.username">sa</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
 </session-factory>
</hibernate-configuration>
 类似资料: