package com.rjlresaka.util;

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

import javax.servlet.ServletContext;

public final class DatabaseConnection {

    private DatabaseConnection() {
    }

    public static Connection getConnection(ServletContext context) throws SQLException, ClassNotFoundException {
        String driver = context.getInitParameter("db.driver");
        String url = context.getInitParameter("db.url");
        String user = context.getInitParameter("db.user");
        String password = context.getInitParameter("db.password");

        Class.forName(driver);
        return DriverManager.getConnection(url, user, password);
    }
}
