/*
** Demonstrates code to load driver and to establish a connection.
*/
import java.sql.*;

public class DBDemo2
{
  public static void main(String args[]) 
    throws ClassNotFoundException,SQLException
  {
    String database="demo_db";
    String url="jdbc:postgresql://csci.hsutx.edu/"+database;
    String username="demo";
    String password="welovethisclass";

    Class.forName("org.postgresql.Driver");   // load the driver
    System.out.print("Driver Loaded Successfully!\n");
    Connection con= DriverManager.getConnection(url,username,password);
    System.out.print("Connection to database '"+database+"' established.\n");
    con.close();   // close connection to database
    System.out.print("Connection to database '"+database+"' closed.\n");
  }
}

