Wednesday 29 August 2012

Connection Pool

Use of Connection Pool - A connection pool is used to minimize the number of connections opened between application and database. It serves as a librarian, checking out connections to application code as needed. Much like a library, your application code needs to be strict about returning connections to the pool when complete, for if it does not do so, your application will run out of available connections.

Problem in Pooling : When using connection pooling, it is important to remember that a chunk of bad code that neglects to return connections can starve the rest of the application, causing it to eventually run out of connections and hang (potentially failing nowhere near the actual problem).

Avoidance of Poling: This problem can be avoided by always using a finally block to close your connection, as shown throughout this book.

What is Specialization in Java?

Specialization means Subclass is specialized version of Super Class 
like Dog is specialized version of Animal i.e  extending a class, 
which is really the opposite of generalization.

Like

class Animal
{

}

class Dog extends Animal //Dog is specialized version of animal
{

}

What is Generalization in Java


> Generalization is the process in which
> we extract common-shared behavior of two or more classes,
> and combine them into a generalized Super Class 


For example:

class dog
{
    void fourLegs()
    {
        System.out.println("four legged animal");
    }
    void bark()
    {
        System.out.println("Bark");
    }
}
class cat

{
    void fourLegs()
    {
        System.out.println("four legged animal");
    }
    void Mew()
    {
        System.out.println("Bark");
    }
}




After Generalization (Shared characterstics are all together)

abstract class Animal
{
    void fourLegs()
    {
        System.out.println("four legged animal");
    } 
}

class dog extends Animal
{
    void bark()
    {
        System.out.println("Bark");
    }
}
class cat extends Animal

{    void Mew()
    {
        System.out.println("Bark");
    }
}


How to delete Multiple records having same value, Using SQL

DELETE
FROM cb_entity_samples A
WHERE ROWID >
  (SELECT MIN(rowid)
  FROM cb_entity_samples B
  WHERE A.fk_specimen = B.fk_specimen
  )