1 24 25 package org.objectweb.cjdbc.scenario.tools.util; 26 27 import java.sql.Connection ; 28 29 import junit.framework.Assert; 30 31 import org.objectweb.cjdbc.common.exceptions.UnreachableBackendException; 32 import org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager; 33 34 39 public class GetConnectionThread extends Thread 40 { 41 42 private AbstractPoolConnectionManager pool; 43 44 45 private long time; 46 47 54 public GetConnectionThread(String name, AbstractPoolConnectionManager pool, 55 long time) 56 { 57 super(name); 58 this.pool = pool; 59 this.time = time; 60 } 61 62 65 public void run() 66 { 67 Connection c = null; 68 try 69 { 70 c = pool.getConnection(); 71 } 72 catch (UnreachableBackendException e1) 73 { 74 Assert.fail("Backend unreachable during test."); 75 } 76 try 77 { 78 Thread.sleep(time); 79 } 80 catch (InterruptedException e) 81 { 82 Assert.fail("Exception thrown: " + e); 83 } 84 pool.releaseConnection(c); 85 } 86 } | Popular Tags |