title: Connecting to database using hibernate - connection url
body: <p>I am trying to connect to a database using hibernate, I have read the documentation and user guild but I still cannot connect to the database.
  The steps which I took:</p>
  
  <ol>
  <li>adding all relevant hibernate jars and <code>sqljdbc41.jar</code> (sql server jdbc driver) to my project.</li>
  <li>added an xml with the following <code>sqljdbc_auth.dll</code> (x64) to the environment path.</li>
  <li><p>created a xml by the name <code>hibernate.cfg.xml</code> with the following connection and dialect:</p>
  
  <pre><code>    &lt;!-- Database connection settings --&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://localhost;databaseName=ForumSystem;integratedSecurity=true;"&lt;/property&gt;
  
  &lt;!-- SQL dialect --&gt;
  &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.SQLServerDialect&lt;/property&gt;
  </code></pre></li>
  </ol>
  
  <p>as you can see my server is local and I am using windows authentication, also I did not change the defualt instance and port.</p>
  
  <p>I try to connection to the databse using the following code:</p>
  
  <pre><code> Configuration configuration = new Configuration();
      configuration.configure();
      serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
              configuration.getProperties()).build();
      sessionFactory = configuration.buildSessionFactory(serviceRegistry);
  </code></pre>
  
  <p>and I get the following error: </p>
  
  <pre><code>Exception in thread "main" org.hibernate.HibernateException: Unable to make JDBC Connection ["jdbc:sqlserver://SHPERB;databaseName=ForumSystem;integratedSecurity=true;"]
  </code></pre>
  
  <p>I have tried to modify the connection url to include the port and the instance name anyway and also tried to connect without windows authentication but made no progress.</p>
  
  <p>Have I missed something? is there a way to know which of the parameters is wrong?</p>
  
  <p><strong>Edit:</strong> forgot to mention that TCP\IP is enabled in the SQL server configuration and that I allow both windows authentication and SQL authentication in the database.
  If I try to connect using:</p>
  
  <pre><code>String connectionUrl = "jdbc:sqlserver://SHPERB;database=ForumSystem;integratedSecurity=true;";
  Connection con = DriverManager.getConnection(connectionUrl);
  </code></pre>
  
  <p>it works, but not using hibernate</p>