package uy.edu.udelar.forrest.forrestloganalyser.webapp;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import javax.servlet.http.HttpServlet;

public class ConsultasBase {

    public static Connection makeConnection() {
        Connection connection = null;
        try {
            Class.forName("org.postgresql.Driver").newInstance();
            connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1/ForrestLogAnalyser","admin","admin");
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }
        return connection;
    }

    public static ResultSet consultar (String cons) {
        ResultSet rs = null;
	try {
	    Connection con = makeConnection();
        Statement stmt = con.createStatement();
	    rs = stmt.executeQuery(cons);
	} catch (Exception e) {
		System.out.println("Exception - " + e.toString());
		e.printStackTrace(System.out);
	}
	return rs;
    }
}
