繁体   English   中英

开发服务器上的JDBC SQL Server连接错误

[英]jdbc sql server connection error on dev server

我正在使用tomee,JPA,并在下面找到配置:

tomee.xml:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
    <Resource id="dataSource" type="DataSource">
         JdbcDriver com.microsoft.sqlserver.jdbc.SQLServerDriver
         JdbcUrl jdbc:sqlserver://******:1433;databaseName=******
         UserName ******
         Password ******
         JtaManaged true
    </Resource>
</tomee>

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
             version="1.0">
   <persistence-unit name="app">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>dataSource</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
         <property name="hibernate.show_sql" value="false"/>
         <property name="hibernate.format_sql" value="false"/>
      </properties>
    </persistence-unit>
</persistence>

这在我的本地计算机上工作正常。 但是,当我尝试将应用程序部署到Dev Linux服务器时,出现了以下异常WARN: HHH000342: Could not obtain connection to query metadata : The TCP/IP connection to the host ******, 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.". WARN: HHH000342: Could not obtain connection to query metadata : The TCP/IP connection to the host ******, 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.".

唯一的区别是localhost是Windows计算机,而dev服务器是Linux计算机。 据我所知,除了主机名外,连接字符串中不需要进行任何更改。

我也尝试使用DB服务器IP地址而不是主机名。 现在服务器卡在了这里: INFO: HHH000130: Instantiating explicit connection provider:org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

请提出您的建议。

我尝试使用jtds并成功。 因此,我认为如果在Linux中使用sql jdbc驱动程序,可能会出现一些问题。

还有一个问题。 当我尝试使用jtds时,遇到了以下异常: java.lang.UnsupportedClassVersionError: net/sourceforge/jtds/jdbc/Driver : Unsupported major.minor version 51.0 我的本地JDK是1.7,而开发服务器JDK是1.6。 然后,我尝试将本地产生的战争部署到Dev服务器。 将服务器JDK更改为1.7后,此问题也得到解决。

需要在数据库服务器上运行一个名为“ SQL Server Browser”的Windows服务,该服务需要重新启动。 该服务被列为正在运行,但未响应查询。 重新启动此服务后,一切都会重新开始。 这是有关此服务的更多信息。

http://msdn.microsoft.com/en-us/library/hh510203.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM