????public static void main(String[] args) throws Exception {
????// TODO Auto-generated method stub
????try {
????// ?????????????????
????ConnectionPoolUtil connPool = new ConnectionPoolUtil("com.mysql.jdbc.Driver"??
????"jdbc:mysql://127.0.0.1:3306/pool"?? "root"?? "root");
????// ?????????????
????connPool.createPool();
????// SQL???????
????String sql = "select * from pool";
????// ?趨??????????????
????long start = System.currentTimeMillis();
????// ???????100???????????
????for (int i = 0; i < 3; i++) {
????Connection conn = connPool.getConnection(); // ????????л??????????????
????Statement stmt = conn.createStatement();
????ResultSet rs = stmt.executeQuery(sql);
????while (rs.next()) {
????String name = rs.getString("userName");
????System.out.println("??????" + name);
????}
????rs.close();
????stmt.close();
????connPool.returnConnection(conn); // ???????????????????????
????}
????System.out.println("????100?ε????????????????????????:" + (System.currentTimeMillis() - start) + "ms");
????// connPool.refreshConnections();//????????????????????????????????????????????У?????????????????????????????????????????
????connPool.closeConnectionPool();// ???????????????????????????
????// ?趨??????????????
????start = System.currentTimeMillis();
????// ????????
????Class.forName("com.mysql.jdbc.Driver");
????for (int i = 0; i < 100; i++) {
????// ????????
????Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/pool"?? "root"?? "root");
????Statement stmt = conn.createStatement();
????ResultSet rs = stmt.executeQuery(sql);
????while (rs.next()) {
????}
????rs.close();
????stmt.close();
????conn.close();// ???????
????}
????System.out.println("????100?ε??????????????????????????:" + (System.currentTimeMillis() - start) + "ms");
????} catch (SQLException e) {
????e.printStackTrace();
????} catch (ClassNotFoundException e) {
????e.printStackTrace();
????}
????}
????}