title: connect postgresql with java
body: <pre><code>package vas;
  
  import java.sql.*;
  public class ConnTO {
  
      public Connection conn;
      private String db;
  
  
      public ConnTO(String db) throws Exception{
  
          this.db=db;
          //Trying to get the driver
          try {
              Class.forName("org.postgresql.Driver");
  
  
  
          }
          catch (java.lang.ClassNotFoundException e) {
              java.lang.System.err.print("ClassNotFoundException: Postgres Server JDBC");
              java.lang.System.err.println(e.getMessage());
              throw new Exception("No JDBC Driver found in Server");
          }
  
          //Trying to connectpostgresql:/
          try {
              conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/"+db,"postgres","211271");
              //conn.setCatalog(db);
              System.out.println("Connection with: "+db+"!!");
          }
          catch (SQLException E) {
  
              java.lang.System.out.println("SQLException: " + E.getMessage());
              java.lang.System.out.println("SQLState: " + E.getSQLState());
              java.lang.System.out.println("VendorError: " + E.getErrorCode());
  
          }
      }
  
  
      //Close Conn
      public void close() throws SQLException{
  
          try {
              conn.close();
              System.out.println("Connection close ");
          } catch (SQLException E) {
  
  
              java.lang.System.out.println("SQLException: " + E.getMessage());
              java.lang.System.out.println("SQLState: " + E.getSQLState());
              java.lang.System.out.println("VendorError: " + E.getErrorCode());
              throw E;
          }
  
      }
  
  
  
  }
  </code></pre>
  
  <p>Hello i create a database with postgresql and i would like to connect it with java but when i run this there is an error such as </p>
  
  <pre><code>ClassNotFoundException: Postgres Server JDBCorg.postgresql.Driver
  java.lang.Exception: No JDBC Driver found in Server
      at vas.ConnTO.&lt;init&gt;(ConnTO.java:21)
      at vas.main.login(main.java:17)
      at vas.main.main(main.java:51)
  </code></pre>
  
  <p>Also i have a main class that i call the class connto and i give the name of my base</p>