title: Spring + Hibernate + Sql Server connection failing
body: <p>I am getting the following error when I am using a combination of Spring, Hibernate and SQL Server.</p>
  
  <pre><code>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.".
  </code></pre>
  
  <p>It could not be just a TCP IP problem, because if I work without Spring, I am able to connect to SQL Server using hibernate.</p>
  
  <p>Below is my applicationContext.xml</p>
  
  <p>
  
  </p>
  
  <pre><code>&lt;!-- Resource Definition --&gt;
  &lt;!-- Data Source Connection Pool --&gt;
  &lt;bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close"&gt;
      &lt;property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /&gt;
      &lt;property name="url" value="jdbc:microsoft:sqlserver://falmumapp20:1433" /&gt;
      &lt;property name="username" value="tima"/&gt;
      &lt;property name="password" value="chalk@"/&gt;
  &lt;/bean&gt;
  
  &lt;!-- Hibernate SessionFactory --&gt;
  &lt;bean id="mySessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="myDataSource" /&gt;
  
      &lt;property name="mappingDirectoryLocations"&gt;
          &lt;list&gt;
              &lt;value&gt;classpath:/com/trun/hbm&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="configLocation"&gt;
         &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
     &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
          &lt;prop key="hibernate.hbm2ddl.auto"&gt;validate&lt;/prop&gt;
          &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/prop&gt;
          &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  
  &lt;/bean&gt;
  
  
  &lt;!--Definition of Transaction Manager--&gt;
  &lt;bean id="myTransactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
      &lt;property name="sessionFactory" ref="mySessionFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>
      </p>
  
  <pre><code>&lt;bean id="IDataService" class="com.trun.service.DataServiceImpl"&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="EventServlet" class="com.trun.servelet.LoginServelet"&gt;
      &lt;property name="IDataDAO" ref="IDataDAO" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is my Hibernate Configuration file -</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
        &lt;property name="hibernate.connection.driver_class"&gt;com.microsoft.sqlserver.jdbc.SQLServerDriver&lt;/property&gt;
        &lt;property name="hibernate.connection.url"&gt;jdbc:sqlserver://falmumapp20:1433;databaseName=testdb; user=tima;password=chalk@;&lt;/property&gt;
        &lt;property name="hibernate.connection.username"&gt;tima&lt;/property&gt;
        &lt;property name="hibernate.connection.password"&gt;chalk@&lt;/property&gt;
        &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt;
        &lt;property name="show_sql"&gt;true&lt;/property&gt;
        &lt;property name="dialect"&gt;org.hibernate.dialect.SQLServer2008Dialect&lt;/property&gt;
        &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;
        &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/property&gt;
        &lt;property name="hibernate.hbm2ddl.auto"&gt;validate&lt;/property&gt;
        &lt;!-- Mapping files --&gt;
  
  &lt;/session-factory&gt;
  </code></pre>