jdbc 连接池

1. 

2. 

b) C3P0

 

 

 

/**

 *

3.  int max_count = 6; // new LinkedList<Connection>();

 

 

//1.  int i=0; i<init_count; i++){

//

//

try {

Class.forName(“com.mysql.jdbc.Driver”);

//

//

new InvocationHandler() { //

//

System.out.println(“begin:

System.out.println(“end:

}

return result;

}

}

);

return proxy;

} catch (Exception e) {

throw new RuntimeException(e);

}

}

 

//3.

return pool.removeFirst();

}

 

// 3.2

// new RuntimeException(“void realeaseConnection(Connection con) {

// 4.1

con.close();

} catch (SQLException e) {

throw new RuntimeException(e);

}

}

}

 

public static void main(String[] args) throws SQLException {

MyPool pool = new MyPool();

System.out.println(“

pool.getConnection();

Connection con4 = pool.getConnection();

Connection con3 = pool.getConnection();

Connection con2 = pool.getConnection();

Connection con1 = pool.getConnection();

 

//

 

System.out.println(“

}

 

}

 

 

 

 

public class App_DBCP {

 

// 1.

//

//

}

 

@Test

// 2.

//

//

con.prepareStatement(“delete from admin where id=4”).executeUpdate();

//

配置方式实现

 

1.2 C3P0

 

public class App {

 

@Test

//1. new ComboPooledDataSource();

//

//

}

 

@Test

//2. XMLnew ComboPooledDataSource();//

//

 

}

}

 

 

1.3 

2. 来源:oschina_39664569

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2017年7月10日
下一篇 2017年7月10日

相关推荐