Hikari Connection Pool 사용하기
Hikari Download
HikariCP Class 구현
public class HikariConnectionPool {
private static HikariConnectionPool instance = null;
private HikariDataSource ds;
public HikariConnectionPool() {
HikariConfig config = new HikariConfig();
config.setDriverClassName("DRIVERCLASS");
config.setJdbcUrl("JDBCURL");
config.setUsername("USER");
config.setPassword("PASSWORD");
ds = new HikariDataSource(config);
}
public Connection getConnect(){
Connection connection = null;
try {
connection = ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
public static HikariConnectionPool getInstance(){
if ( instance == null ){
instance = new HikariConnectionPool();
}
return instance;
}
}
HikariCP Driver Class Name은
https://github.com/brettwooldridge/HikariCP#popular-datasource-class-names
참조하여 사용.
'프로그래밍 > Java' 카테고리의 다른 글
[Java] Caller Trace (호출 추적하기) (0) | 2016.10.06 |
---|---|
[Java] System.out의 결과를 파일로 출력 (0) | 2016.06.15 |
[Java] 가변인자 ( Varargs ) (0) | 2013.03.13 |
[Java] Sub Class의 필요성 (0) | 2012.10.03 |
[Java] 천단위 콤마 추가, 제거 (0) | 2012.07.26 |