title: failed.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect with PostGres Hibernate
body: <p>I keep getting this error, here are my files</p>
  
  <p><strong>hibernate.cfg.xml</strong>
  
  </p>
  
  <p>
      </p>
  
  <pre><code>    &lt;!-- Database connection settings --&gt;
      &lt;property name="connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
      &lt;property name="connection.url"&gt;jdbc:postgresql://localhost:5432/postgres&lt;/property&gt;
      &lt;property name="connection.username"&gt;postgres&lt;/property&gt;
      &lt;property name="connection.password"&gt;postgres&gt;&lt;/property&gt;
  
      &lt;property name="hibernate.default_schema"&gt;hibernate_test&lt;/property&gt;
  
      &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.PostgreSQL82Dialect&lt;/property&gt; 
  
      &lt;!-- Disable the second-level cache  --&gt;
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup  --&gt;
      &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  
      &lt;mapping class="com.de.entity.Employee"&gt;&lt;/mapping&gt;
  
  &lt;/session-factory&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>HibernateUtil.java</strong></p>
  
  <pre><code>package com.de.config;
  
  import org.hibernate.SessionFactory;
  import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
  import org.hibernate.cfg.Configuration;
  import org.hibernate.service.ServiceRegistry;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  
  /**
   * Sets up the connection the DB and Hibernate
   * @author de
   *
   */
  public class HibernateUtil {
  
      private static final Logger logger = LoggerFactory.getLogger(HibernateUtil.class);
  
      private static final SessionFactory sessionFactory = buildSessionFactory(); 
  
  
      private static SessionFactory buildSessionFactory() {
          logger.info("Creating Hibernate Session Factory");
          try{
              // Create the SessionFactory form hibernate.cfg.xml
              Configuration configuration = new Configuration();
              configuration.configure("hibernate.cfg.xml");
              logger.info("Hibernate Configuration loaded");
              logger.info("Configuration: " + configuration.getProperties());
              ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
              SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
              return sessionFactory;
          } catch (Throwable ex) {
              logger.error("Initial SessionFactory creation failed." + ex);
              throw new ExceptionInInitializerError(ex);
          }
  
      }
  
      public static SessionFactory getSessionFactory() {
          return sessionFactory;
      }
  
  }
  </code></pre>
  
  <p>Here is a better snippet of the error</p>
  
  <pre><code>09:47:23,829  WARN DriverManagerConnectionProviderImpl:93 - HHH000402: Using Hibernate built-in connection pool (not for production use!)
  09:47:23,846  INFO DriverManagerConnectionProviderImpl:166 - HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/postgres]
  09:47:23,848  INFO DriverManagerConnectionProviderImpl:175 - HHH000046: Connection properties: {user=postgres, password=****}
  09:47:23,849  INFO DriverManagerConnectionProviderImpl:180 - HHH000006: Autocommit mode: false
  09:47:23,852  INFO DriverManagerConnectionProviderImpl:102 - HHH000115: Hibernate connection pool size: 1 (min=1)
  09:47:23,922 ERROR HibernateUtil:35 - Initial SessionFactory creation failed.org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
  </code></pre>
  
  <p>I've been trying my best to figure out what this issue is.
  I downloaded Navicat for Postgres and I was able to successfully connect to it using the connection url and username/password. So I narrowed out the connection information being incorrect.</p>
  
  <p>Just for completion...</p>
  
  <p>Here is my 
  <strong>pom.xml</strong></p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;com.de.test&lt;/groupId&gt;
      &lt;artifactId&gt;test&lt;/artifactId&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;testMaven Webapp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
      &lt;properties&gt;
          &lt;slf4jVersion&gt;1.7.7&lt;/slf4jVersion&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
  
          &lt;!-- Persistence --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;ejb3-persistence&lt;/artifactId&gt;
              &lt;version&gt;1.0.2.GA&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
              &lt;version&gt;4.3.5.Final&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.validation&lt;/groupId&gt;
              &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
              &lt;version&gt;1.0.0.GA&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;!--    &lt;dependency&gt;
              &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
              &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
              &lt;version&gt;4.0.2.GA&lt;/version&gt;
          &lt;/dependency&gt; --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;version&gt;9.3-1100-jdbc41&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.github.dzwicker.dart&lt;/groupId&gt;
              &lt;artifactId&gt;dart-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.0.8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javassist&lt;/groupId&gt;
              &lt;artifactId&gt;javassist&lt;/artifactId&gt;
              &lt;version&gt;3.12.1.GA&lt;/version&gt;
          &lt;/dependency&gt;
  
  
  
          &lt;!-- REST / WEB --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
              &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
              &lt;version&gt;2.5&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-common&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
              &lt;version&gt;2.8&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;com.fasterxml.jackson.jaxrs&lt;/groupId&gt;
              &lt;artifactId&gt;jackson-jaxrs-json-provider&lt;/artifactId&gt;
              &lt;version&gt;2.2.3&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;!-- Logging --&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
              &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
              &lt;version&gt;${slf4jVersion}&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;!-- Testing --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;4.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
  
  
      &lt;build&gt;
          &lt;finalName&gt;test&lt;/finalName&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>