KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SimpleGenericPool


1
2 import org.enhydra.jdbc.pool.GenericPool;
3 import org.enhydra.jdbc.util.Logger;
4 import org.apache.commons.logging.LogFactory;
5
6 public class SimpleGenericPool {
7     static public void main(String JavaDoc[] argv) throws Exception JavaDoc{
8
9         GenericPool genPool = new GenericPool(new SimplePoolHelper(), 4);
10         genPool.setLogger(new Logger(LogFactory.getLog("simplepool")));
11         System.out.println("set the max size of the pool");
12         genPool.setMaxSize(10);
13         System.out.println("set the min size of the pool");
14         genPool.setMinSize(2);
15
16         System.out.println("start the pool");
17         genPool.start();
18
19         System.out.println("get a car from the pool");
20         Car aCar = (Car)(genPool.checkOut(null, null));
21         aCar.setBrand("Mercedes");
22         aCar.setColor("black");
23
24         System.out.println("get another car from the pool");
25         Car anotherCar = (Car)(genPool.checkOut(null, null));
26         anotherCar.setBrand("Porsche");
27         anotherCar.setColor("red");
28
29         System.out.println("stop the pool");
30         genPool.stop();
31         System.exit(1);
32     }
33 }
34
Popular Tags