I'm adding connections into arraylist and geting one by one connections when i need to use them, Here I'm using connection from connection pool,
ArrayList<Connection> al=new ArrayList<Connection>();
public Connection getconnection(){
if(al.size()>0)
{
try{
connection = al.get(0);
al.remove(connection);
}catch(Exception e){
out.print(e);
}
}else{
out.println("No Database connection is Available !");
}
return connection;
}
After using this connection I'm returning it back to connection pool.
public void returnconnection(Connection con){
Connection c = con;
al.add(c);
out.println("Hi I'm Connection, I'm back! ");
}
Here I need to check this connection is live or not before adding to the ArrayList ??