title: Eclipse and postgres JDBC connection
body: <p>i'm making a java web project and using Postgres for the database, but i can't get it to work, i'm using the most recent versions of all software (eclipse, postgres, tomcat) and drivers (JDBC postgres connection driver).</p>
  
  <p>Here is my connection string:</p>
  
  <pre><code>private Connection getConnection() throws ClassNotFoundException,
              SQLException {
          if (cx == null) {
              String url = "jdbc:postgresql://localhost:5432/gregory";
              String login = "postgres";
              String senha = "postgres";
          //  Class.forName("org.postgresql.Driver");
              cx = DriverManager.getConnection(url, login, senha);
  
          }
          return cx;
  
      }
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>HTTP Status 500 - javax.servlet.ServletException: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/gregory
  </code></pre>
  
  <p>When i uncomment the class.forname line, i get this error instead:</p>
  
  <pre><code>javax.servlet.ServletException: java.lang.ClassNotFoundException: org.postgresql.Driver
  </code></pre>
  
  <p>I've added the postgres driver to the WEB-INF/lib folder, the root folder, tomcat's lib folder and the folder where my database access class is, the outcome is the same. I also added it through eclipse, myProject -> properties -> libraries -> add external JARs and tried to use JDBC4 and 3, and i have no results yet. Getting rather desperate here, any help would be very welcome.</p>