JDBC_eclipse platform1.htm
  • Importing Jars : Eclipse
    •  Right click on your project
    • Choose property
    • Choose Java build path
    • Choose add external JARS.. and select the location to the JDBC driver.
  • // Class.forName("org.postgresql.Driver");
  • c = DriverManager
    "postgres", "postgre_manas9");

Java Build Path>> Libraries:

Select and click on External jars:

Added  PostgreSQL jars to this template as an external jars:

Same add MySQL drivers:

Code Used :

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 {
c = DriverManager
"postgres", "postgre_manas9");
} catch (Exception e) {
System.err.println(e.getClass().getName()+": "+e.getMessage());
System.out.println("Connected to database successfully");