package DBcon;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import javax.servlet.ServletContext;

public class DataCon
{

    public DataCon()
    {
    }

    public Connection getConnection(ServletContext servletcontext)
    {
        Connection connection = null;
        try
        {
            String s = "/WEB-INF/classes/DBInfo.properties";
            java.io.InputStream inputstream = servletcontext.getResourceAsStream(s);
            Properties properties = new Properties();
            properties.load(inputstream);
            Class.forName(properties.getProperty("driver"));
            connection = DriverManager.getConnection(properties.getProperty("url"), properties.getProperty("user"), properties.getProperty("pass"));
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
            System.out.println(exception.toString());
        }
        return connection;
    }
}