title: How to resolve 'No suitable driver found' error
body: <p>I am running Netbeans 8.0.2. I was learning about JDBC and wanted to connect it to a PostgreSQL database. I looked up for all possible answers but no answer made it work. </p>
  
  <p>I have also chosen the library on the left side menu as <code>PostgreSQL JDBC Driver -postgresql-9.2-1002.jdbc4.jar</code></p>
  
  <p>The error shown is: </p>
  
  <blockquote>
    <p>SQL exception occuredjava.sql.SQLException: No suitable driver found
    for Jdbc:postgresql://localhost:5432/postgres</p>
  </blockquote>
  
  <p>Here's the code:</p>
  
  <pre><code>try   { 
  
      Class.forName("org.postgresql.Driver");
  
    }
    catch(ClassNotFoundException e) {
       System.out.println("Class not found "+ e);
    }
       try {
  
       Connection con = DriverManager.getConnection
       ("Jdbc:postgresql://localhost:5432/postgres","postgres",
       "gautam");
  
       Statement stmt = con.createStatement();
       ResultSet rs = stmt.executeQuery
       ("SELECT * FROM role");
       System.out.println("id  name");
  
       while (rs.next()) {
          int id = rs.getInt("id");
          String name = rs.getString("name");
          System.out.println(id+"   "+name);
  
       }
    }
    catch(SQLException e){
       System.out.println("SQL exception occured" + e);
    }
  </code></pre>