1. 커넥션풀이란?
커넥션풀이란 객체를 미리 생성해 풀(pool)에 넣어놓고 요청이 있을 때마다 이미 생성된 Connection 객체를 가져다 쓰고 다시 반환하는 방법이다. 사용이 끝난 객체를 연결 해제하지 않고 반납하여 다시 사용할 수 있도록 하는 것이다.
복잡성을 줄이기 위해 환경설정과 연결 관리 등은 xml파일에서 따로 관리하고
필요할 때마다 획득하여 사용하는 것이다.
2. 커넥션풀 사용하는법 - MySQL

Server에 context.xml에 들어간다.
- context.xml
<Resource name="jdbc/mysql"
        type="javax.sql.DataSource"
        auth="Container"
         maxActive="30"
        maxIdle="3"
        maxWait="3000"
        username="본인사용자이름"
        password="본인MySQL패스워드"
        testOnBorrow="true"
        driverClassName="com.mysql.cj.jdbc.Driver"
        url="jdbc:mysql://localhost:3306/DB이름?useSSL=false&serverTimezone=UTC"/>
- 본 Server의 context.xml 에 삽입
 - 자바 클래스에 /musthave?useSSL=false&serverTimezone=UTC 적었던 것을 아래와 같이 적어야한다.
 - /musthave?useSSL=false&serverTimezone=UTC
 - "&" => "&" 라고 적어줘야 오류가 나지 않는다.
 
커넥션풀을 이용한 자바클래스
-DBConnPool.java
package common;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class DBConnPool {
	public Connection con;
	public Statement stmt;
	public PreparedStatement psmt;
	public ResultSet rs;
	
	public DBConnPool() {
		try {
			Context initCtx = new InitialContext();
			Context ctx = (Context)initCtx.lookup("java:comp/env");
			DataSource source = (DataSource)ctx.lookup("jdbc/mysql");
			
			con = source.getConnection();
			
			System.out.println("DB Connection Pool success");
		} catch (Exception e) {
			System.out.println("DB Connection Pool fail");
			e.printStackTrace();
		}
		
	}
	
	public void close() {
		try {
			if (rs != null) rs.close();
			if(stmt != null) stmt.close();
			if(psmt != null) psmt.close();
			if(con != null) con.close();
			
			System.out.println("JDBC Disconnection!");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
위와 같이 구성해주면 커넥션풀을 사용할 수 있다.