Question

I am using tomee, JPA and find below the configuration:

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>

This is working fine on my local. But when I tried to deploy my application to Dev Linux server, I am getting this exception 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.".

The only difference is localhost is windows machine and dev server is Linux machine. As far as I know for this there are no changes required in connection string except the host name.

I also tried with DB server IP address instead of host name. Now server is stuck at this point: INFO: HHH000130: Instantiating explicit connection provider:org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

Please give your suggestions.

Was it helpful?

Solution

I tried with jtds and it worked. So I think there might be some issues if we use sql jdbc driver in linux.

There was one more issue. When I tried with jtds, I got this exception: java.lang.UnsupportedClassVersionError: net/sourceforge/jtds/jdbc/Driver : Unsupported major.minor version 51.0. My local JDK was 1.7 and Dev server JDK was 1.6. And I tried to deploy the war generated from my local to Dev server. Once I changed server JDK to 1.7 this issue also got resolved.

OTHER TIPS

There’s a Windows service that runs on the database server called the “SQL Server Browser” that needed to be restarted. The service was listed as running, but it wasn’t responding to queries. As soon as we restarted this service everything started working again. Here’s some more information on this service.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top