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