The java code establishes postgresql database connection .
import java.sql.*;
import java.text.*;
import java.io.*;
//class
public class BioappAPI
{
Connection db;
DatabaseMetaData dbmd;
/**
* The constructor of BioApp API class It establishes connection with the database
* and intitializes the class variables
* @param argv a String array that contains database name,username and password
*/
//Constructor
public BioappAPI(String argv[])
throws ClassNotFoundException, SQLException
{
String database = argv[0];
String username = argv[1];
String password = argv[2];
try
{
Class.forName("org.postgresql.Driver");
db = DriverManager.getConnection("jdbc:postgresql:"+database,username,password);
dbmd = db.getMetaData();
System.out.println("Connection to "+dbmd.getDatabaseProductName()+" "+
dbmd.getDatabaseProductVersion()+" successful.
");
}//end of try
catch(Exception e)
{
e.printStackTrace() ;
System.out.println("
Connection could not be established!");
}
}//end of constructor
}//end of class