title: Adding postgresql DB to travis
body: <p>It's my first time using any CI. I have used Travis. In current commit I added <code>postgresql</code>, but it is failing building (on my computer (local) it is working correctly) with stacktrace: (whole stacktrace <a href="https://travis-ci.org/must1/BookstoreScraper/builds/568424005?utm_source=github_status&amp;utm_medium=notification" rel="nofollow noreferrer">https://travis-ci.org/must1/BookstoreScraper/builds/568424005?utm_source=github_status&amp;utm_medium=notification</a>)</p>
  
  <pre><code>org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
      at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:280) ~[postgresql-42.2.5.jar:42.2.5]
      at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5]
      at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5]
      at org.postgresql.Driver.makeConnection(Driver.java:454) ~[postgresql-42.2.5.jar:42.2.5]
      at org.postgresql.Driver.connect(Driver.java:256) ~[postgresql-42.2.5.jar:42.2.5]
      at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:136) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:369) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:198) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:467) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:541) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.pool.HikariPool.&lt;init&gt;(HikariPool.java:115) ~[HikariCP-3.2.0.jar:na]
      at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112) ~[HikariCP-3.2.0.jar:na]
      at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:151) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:115) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:78) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:319) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:356) ~[spring-jdbc-5.1.3.RELEASE.jar:5.1.3.RELEASE]
      at org.springframework.boot.autoconfigure.orm.jpa.DatabaseLookup.getDatabase(DatabaseLookup.java:73) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
      at org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.determineDatabase(JpaProperties.java:142) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
      at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.jpaVendorAdapter(JpaBaseConfiguration.java:112) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
      at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$314b4507.CGLIB$jpaVendorAdapter$5(&lt;generated&gt;) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
      at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration$$EnhancerBySpringCGLIB$$314b4507$$FastClassBySpringCGLIB$$ae85cd83.invoke(&lt;generated&gt;) ~[spring-boot-autoconfigure-2.1.1.RELEASE.jar:2.1.1.RELEASE]
      at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
  </code></pre>
  
  <p>I knwo that it cannot find postgres, but I don't know how to add it.</p>
  
  <p><code>travis.yml</code> configuration: </p>
  
  <pre><code>language: java
  
  addons:
    sonarcloud:
      organization: "must1"
      token:
        secure: TOKEN # encrypted value of your token
  
  script:
    # the following command line builds the project, runs the tests with coverage and then execute the SonarCloud analysis
    - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
  </code></pre>
  
  <p><code>application.properties</code></p>
  
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/bookstore_scraper
  spring.datasource.username=postgres
  spring.datasource.password=1234
  spring.jpa.hibernate.ddl-auto=create-drop
  spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults= false
  </code></pre>