Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹簧&x2B;冬眠+;Sql Server连接失败_Java_Spring_Hibernate - Fatal编程技术网

Java 弹簧&x2B;冬眠+;Sql Server连接失败

Java 弹簧&x2B;冬眠+;Sql Server连接失败,java,spring,hibernate,Java,Spring,Hibernate,当我结合使用Spring、Hibernate和SQL Server时,出现以下错误 19:17:09,137 ERROR [org.hibernate.tool.hbm2ddl.SchemaValidator] (MSC service thread 1-8) HHH000319: Could not get database metadata: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to t

当我结合使用Spring、Hibernate和SQL Server时,出现以下错误

19:17:09,137 ERROR [org.hibernate.tool.hbm2ddl.SchemaValidator] (MSC service thread 1-8) HHH000319: Could not get database metadata: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host falmumapp20/testdb, port 1433 has failed. Error: "null. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
这可能不仅仅是一个TCP IP问题,因为如果我在没有Spring的情况下工作,我就能够使用hibernate连接到SQL Server

下面是我的applicationContext.xml


类路径:/com/trun/hbm
类路径:hibernate.cfg.xml
验证
org.hibernate.dialogue.sqlserverdialogue
真的


这是我的Hibernate配置文件-

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
      <property name="hibernate.connection.url">jdbc:sqlserver://falmumapp20:1433;databaseName=testdb; user=tima;password=chalk@;</property>
      <property name="hibernate.connection.username">tima</property>
      <property name="hibernate.connection.password">chalk@</property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
      <property name="hibernate.current_session_context_class">thread</property>
      <property name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
      <property name="hibernate.hbm2ddl.auto">validate</property>
      <!-- Mapping files -->

</session-factory>

com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc:sqlserver://falmumapp20:1433;databaseName=testdb;用户=tima;密码=粉笔@;
蒂玛
粉笔@
10
真的
org.hibernate.dialogue.sqlserver2008dialogue
线
org.hibernate.cache.internal.NoCacheProvider
验证

您没有将数据库名称传递给连接url

<property name="url" value="jdbc:sqlserver://falmumapp20:1433;databaseName=testdb" />



对。不需要hibernate配置文件中的所有hibernate.connection.*属性,因为这是由datasource.cn管理的。我已经做了修改,现在它给出了其他错误,我正在自己尝试,并将返回论坛-a+1关于您的回答(我:)谢谢您的评论和反馈:)
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
      <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
      <property name="hibernate.connection.url">jdbc:sqlserver://falmumapp20:1433;databaseName=testdb; user=tima;password=chalk@;</property>
      <property name="hibernate.connection.username">tima</property>
      <property name="hibernate.connection.password">chalk@</property>
      <property name="hibernate.connection.pool_size">10</property>
      <property name="show_sql">true</property>
      <property name="dialect">org.hibernate.dialect.SQLServer2008Dialect</property>
      <property name="hibernate.current_session_context_class">thread</property>
      <property name="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
      <property name="hibernate.hbm2ddl.auto">validate</property>
      <!-- Mapping files -->

</session-factory>
<property name="url" value="jdbc:sqlserver://falmumapp20:1433;databaseName=testdb" />
<property name="url" value="jdbc:sqlserver://falmumapp20:1433/testdb" />