Java Build Path>> Libraries:
Select and click on External jars:
Added PostgreSQL jars to this template as an external jars:
Same add MySQL drivers:
package manas.com; import java.io.*; import java.sql.Connection; import java.sql.DriverManager; public class JavaTemplate1 { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Hello world"); Connection c = null; try { //Class.forName("org.postgresql.Driver"); c = DriverManager .getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "postgre_manas9"); } catch (Exception e) { e.printStackTrace(); System.err.println(e.getClass().getName()+": "+e.getMessage()); System.exit(0); } System.out.println("Connected to database successfully"); } }