HikariCP是一个高性能的JDBC连接池组件。下图是性能的比较测试结果:
使用方法:
HikariCofig cofig = ew HikariCofig();cofig.setMaximumPoolSize(100);cofig.setDataSourceClassName("com.mysql.jdbc.jdbc2.optioal.MysqlDataSource");cofig.addDataSourceProperty("serverName", "localhost");cofig.addDataSourceProperty("port", "3306");cofig.addDataSourceProperty("databaseName", "mydb");cofig.addDataSourceProperty("user", "bart");cofig.addDataSourceProperty("password", "51mp50");HikariDataSource ds = ew HikariDataSource(cofig);或者:
/**coectioTestQuery=SELECT 1dataSourceClassName=org.postgresql.ds.PGSimpleDataSourcedataSource.user=testdataSource.password=testdataSource.databaseName=mydbdataSource.serverName=localhost*/HikariCofig cofig = ew HikariCofig("some/path/hikari.properties");HikariDataSource ds = ew HikariDataSource(cofig);Mave:
<depedecy> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> <versio>1.3.5</versio> <scope>compile</scope></depedecy>
评论