title: postgresql jdbc: FATAL: database does not exist
body: <p>I'm trying to connect to a database using the following code:</p>
  
  <pre><code>import java.sql.SQLException;
  import java.sql.DriverManager;
  import java.sql.Connection;
  import java.sql.Statement;
  import java.sql.ResultSet;
  
  public class Model {
  
          Connection connection;
  
          Model() {
  
                  try {
                          connection = DriverManager.getConnection("jdbc:postgresql:localhost:5432/deliverp", "kais", "0000");
                  }
                  catch (SQLException e) {
                          e.printStackTrace();
                  }
          }
  
          static {
  
                  try {
                          Class.forName("org.postgresql.Driver");
                  }
                  catch (ClassNotFoundException e) {
                          e.printStackTrace();
                  }
          }
  
          public boolean addClient(Object data[]) {
  
                  return true;
          }
  }
  </code></pre>
  
  <p>But after running the Java program I receive the following stack trace:</p>
  
  <pre><code>Nov 17, 2017 8:58:24 AM org.postgresql.Driver connect
  SEVERE: Connection error: 
  org.postgresql.util.PSQLException: FATAL: database "localhost:5432/deliverp" does not exist
          at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)
          at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2603)
          at org.postgresql.core.v3.QueryExecutorImpl.&lt;init&gt;(QueryExecutorImpl.java:125)
          at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:227)
          at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
          at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:194)
          at org.postgresql.Driver.makeConnection(Driver.java:450)
          at org.postgresql.Driver.connect(Driver.java:252)
          at java.sql.DriverManager.getConnection(DriverManager.java:664)
          at java.sql.DriverManager.getConnection(DriverManager.java:247)
          at Model.&lt;init&gt;(Model.java:16)
          at DelivERP.&lt;init&gt;(DelivERP.java:42)
          at DelivERP.main(DelivERP.java:104)
  
  org.postgresql.util.PSQLException: FATAL: database "localhost:5432/deliverp" does not exist
          at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477)
          at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2603)
          at org.postgresql.core.v3.QueryExecutorImpl.&lt;init&gt;(QueryExecutorImpl.java:125)
          at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:227)
          at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
          at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:194)
          at org.postgresql.Driver.makeConnection(Driver.java:450)
          at org.postgresql.Driver.connect(Driver.java:252)
          at java.sql.DriverManager.getConnection(DriverManager.java:664)
          at java.sql.DriverManager.getConnection(DriverManager.java:247)
          at Model.&lt;init&gt;(Model.java:16)
          at DelivERP.&lt;init&gt;(DelivERP.java:42)
          at DelivERP.main(DelivERP.java:104)
  </code></pre>
  
  <p>Therefore I wanted to make sure that the database exists by running the test below:</p>
  
  <pre><code>kais@debian:~/Documents/DelivERP$ psql deliverp
  psql (9.6.4)
  Type "help" for help.
  
  deliverp=&gt; \d
               List of relations
   Schema |      Name      | Type  |  Owner   
  --------+----------------+-------+----------
   public | BusinessEntity | table | postgres
   public | Client         | table | postgres
   public | Company        | table | postgres
   public | Order          | table | postgres
   public | Product        | table | postgres
  (5 rows)
  
  deliverp=&gt; 
  </code></pre>
  
  <p>It sounds to me weird that the server didn't find the database although it exists ..</p>
  
  <p>Any thoughts?</p>