HikariCP--一款高性能的 JDBC 连接池
阅读原文时间:2023年07月15日阅读:1

源码地址:https://github.com/brettwooldridge/HikariCP

使用方法:

Java 8 maven artifact:

<dependency>  
    <groupId>com.zaxxer</groupId>  
    <artifactId>HikariCP</artifactId>  
    <version>2.6.1</version>  
</dependency>

Java 7 maven artifact (_maintenance mode):_

<dependency>  
    <groupId>com.zaxxer</groupId>  
    <artifactId>HikariCP-java7</artifactId>  
    <version>2.4.11</version>  
</dependency>

Java 6 maven artifact (_maintenance mode):_

<dependency>  
    <groupId>com.zaxxer</groupId>  
    <artifactId>HikariCP-java6</artifactId>  
    <version>2.3.13</version>  
</dependency>

初始化

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");
config.setUsername("bart");
config.setPassword("51mp50n");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

HikariDataSource ds = new HikariDataSource(config);