title: Connecting to local instance of PostgreSql with JDBC
body: <p>I have a running local instance of PostgreSql on a linux machine. When I use <code>psql</code> command from the shell I success to log in without any problem. I need to connect to the PostgreSql via the JDBC, but I don't know what exactly should I pass as <code>url</code> parameter to <code>DriverManager.getConnection()</code>.</p>
  
  <p>It should start with <code>jdbc:postgresql:</code> but what's going next?</p>
  
  <p>I was told by the system group that a database with was created like user name. e.g. if my user is <code>jutky</code> a db named <code>jutky</code> was created, but when I try to open a connection to <code>jdbc:postgresql:jutky</code> I get an error </p>
  
  <p><code>org.postgresql.util.PSQLException: FATAL: password authentication failed for user "jutky"</code>
  :(</p>
  
  <p><em>Additional info</em></p>
  
  <p>When I login via the <code>psql</code> I'm not prompted for the password, so when I try to login via JDBC I pass an empty string as a password - is it correct, or should I pass <code>null</code> or something?</p>
  
  <p>When I type <code>psql --help</code> in the shell I see among the rest this line:   </p>
  
  <pre><code>Connection options:
     -h, --host=HOSTNAME      database server host or socket directory (default: "/var/run/postgresql")
  </code></pre>
  
  <p>So I understand that I connect to PostgreSql via a <code>socket directory</code>, does that matters something to the URL string in the JDBC?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>First thanks for the answers. </p>
  
  <p>Second: its not first time I'm using JDBC and in particular not the first time I'm connecting to the PostgreSql from JDBC, so I know the general rules and I have read the documentations. However in the described case I'm not sure how exactly should I construct the connection string if the instance is running via the <code>socket directory</code> and what password should I provide. Because when I login via the <code>psql</code> I'm not prompted for password at all.</p>
  
  <p>Thanks in advance.</p>