package model;

import java.sql.Connection;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class ConnectionPool {
	public ConnectionPool() {
	}

	public Connection getConnection() {
		Connection connection = null;
		try {
			Context envCtx = (Context) 
						new InitialContext().lookup("java:comp/env");
			DataSource ds = (DataSource) envCtx.lookup("jdbc/TestDB");
			connection = ds.getConnection();
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
		return connection;
	}

	public static void main(String[] args) {
		ConnectionPool c = new ConnectionPool();
		System.out.println(c.getConnection());
	}
}
