HIKARICP claims to be the best-performing JDBC Connection pool component Now, and I have not tested it carefully, but from what it is now, it may indeed be as high-performance as it has been in the current connection pool component. Before the connection pool memory has been c3p0, DBCP, BONECP, the three BONECP performance is the best, c3p0 performance is now really very poor, as if c3p0 for a long time have not been updated, so we should eliminate the use of C3P0 in the project, As to whether to use HIKARICP, I think we can try. After all, HIKARICP is only out soon, its performance exactly how, also need to practice test, if worry about new things have pit, I recommend using BONECP. Spring is now also integrated with HIKARICP, so I think it's very necessary to try it out. Not long ago I used the HIKARICP in the project, there was no problem, the operation is relatively stable.
HIKARICP on GitHub address: Https://github.com/brettwooldridge/HikariCP
The following is a picture of the performance comparison of 2 HIKARICP and other connection pool components:
You can see the detailed usage documentation on its website, and here's how it's usually used:
Import Java.sql.connection;import Java.sql.sqlexception;import Com.zaxxer.hikari.hikariconfig;import com.zaxxer.hikari.hikaridatasource;/** * HIKARICP Use * @author coolking * */public class DataSource {private Hikaridatasou RCE ds;/** * Initialize connection pool * @param minimum * @param Maximum */public void init (int minimum,int Maximum) {//Connection pool configuration Hikariconfig conf IG = new Hikariconfig (); Config.setdriverclassname ("Com.mysql.jdbc.Driver"); Config.setjdbcurl ("jdbc:mysql:// 127.0.0.1:3306/testdb?user=root&password=123456&useunicode=true&characterencoding=utf8 "); Config.adddatasourceproperty ("Cacheprepstmts", true); Config.adddatasourceproperty ("Prepstmtcachesize", 500); Config.adddatasourceproperty ("Prepstmtcachesqllimit", 2048); Config.setconnectiontestquery ("Select 1"); Config.setautocommit (TRUE);//The minimum number of idle links in the pool config.setminimumidle (minimum);//The maximum number of links in the pool config.setmaximumpoolsize ( Maximum);d s = new Hikaridatasource (config);} /** * Destroy connection pool */public void shutdown () {Ds.shutdown ();} /** * Get the link from the connection pool * @return */public COnnection getconnection () {try {return ds.getconnection ();} catch (SQLException e) {e.printstacktrace ();d S.resumepool ( ); return null;}} public static void Main (string[] args) throws SQLException {DataSource ds = new DataSource ();d S.init (10, 50); Connection conn = Ds.getconnection ();//......//finally closes the link conn.close ();}}
In addition, HIKARICP need to rely on the following several jars
Slf4j-api-1.7.12.jar
Metrics-core-3.0.2.jar
Metrics-healthchecks-3.1.2.jar
Javassist-3.19.0-ga.jar
Hikaricp-2.3.5.jar
If you use MySQL, you also need to Mysql-connector-java-5.0.8-bin.jar
The above jar with HIKARICP needs can be downloaded to http://download.csdn.net/detail/abc_key/8790543 this address
The best-performing JDBC Connection pool: HIKARICP