package io.github.programminglife2016.pl1_2016.parser.metadata;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by ravishivam on 8-5-16.
 */
public class MetaDatabase {

    private static final String DATABASE_DRIVER = "org.postgresql.Driver";

    private static final String HOST = "jdbc:postgresql://127.0.0.1:5432/PL1";

    private static final String ROLL = "postgres";

    private static final String PASSWORD = "visual";

    private Connection connection;

    public MetaDatabase() {
        connectDatabase();
    }

    /**
     * Sets up the driver and creates a connection with database with given host and rolls.
     */
    private void connectDatabase() {
        try {
            Class.forName(DATABASE_DRIVER);
        } catch (ClassNotFoundException e) {
            System.out.println("Driver not included in dependencies. Update Maven!");
            e.printStackTrace();
        }
        Connection connection = null;
        try {
            connection = DriverManager.getConnection(HOST, ROLL, PASSWORD);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        this.connection = connection;
    }

    public static void main(String[] argv) {

    }
}

@@ -78,79 +78,9 @@
 sql.
-Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.SQLException
+*
 ;%0A%0A/
@@ -290,24 +290,28 @@
 ://1
-27.0.0.1
+45.94.157.33
 :5432/
-PL
+pl
 1%22;%0A
@@ -352,23 +352,17 @@
 OLL = %22p
-ostgres
+l
 %22;%0A%0A    
@@ -517,16 +517,18 @@
     /**%0A
+h%0A
      * S
@@ -1182,19 +1182,408 @@
 %5D argv) 
-%7B%0A%0A
+throws SQLException %7B%0A        MetaDatabase db = new MetaDatabase();%0A        String sql = %22SELECT Specimen_ID, Age, Sex FROM specimen;%22;%0A        PreparedStatement stm = db.connection.prepareStatement(sql);%0A        ResultSet set = stm.executeQuery();%0A        while(set.next())%7B%0A            System.out.println(set.getString(1));%0A        %7D%0A        stm.close();%0A        db.connection.close();%0A    
     %7D%0A%7D%0A

Add initial databaseconnection