This discussion is archived
4 Replies Latest reply: Feb 14, 2013 4:24 PM by jschellSomeoneStoleMyAlias RSS

How to close connections physically in UCP

633467 Newbie
Currently Being Moderated
Dear All,

While using the Universal Connection Pooling, when the maximum number connections are borrowed; subsequent requests for a connection result in new connection.
And, it keeps on increasing the number of borrowed connections. Thereafter, if connections are closed, the connections keeps on returning to the pool and become available for further request(s).
At this stage, if too many connections are available, it affects the system performance. Is there any way to physically close the connections ?

Also, is there any feature in UCP similar to close() method in OracleConnectionCacheImpl (Which closes all the physical connections available in the pool) ?

Thanks,
Sachin
  • 1. Re: How to close connections physically in UCP
    rp0428 Guru
    Currently Being Moderated
    All of that functionality and more is covered in the UCP for JDBC Dev Guide
    http://docs.oracle.com/cd/E14072_01/java.112/e12265/connect.htm#CHDIBEAE
    >
    Removing Connections from UCP
    The setInvalid method of the ValidConnection interface indicates that a connection should be removed from the connection pool when it is closed. The method is typically used when a connection is no longer usable, such as after an exception or if the isValid method of the ValidConnection interface returns false. The method can also be used if an application deems the state on a connection to be bad. The following example demonstrates using the setInvalid method to close and remove a connection from the pool:

    Connection conn = pds.getConnection();
    ...

    ((ValidConnection) conn).setInvalid();
    ...

    conn.close();
    conn=null;
  • 2. Re: How to close connections physically in UCP
    633467 Newbie
    Currently Being Moderated
    The connection are getting successfully physcially closed by finding the no of available connections, borrowing each individual connection, setting them to invalid and closing the connection. (as in documentation)
    How can we close the connection(s) which are currently in use (borrowed) ? Is it the right way to cache references of all the connections either borrowed or available within the pool ?
    If all the connections are available, all connections can be physically closed irrespective of being borrowed or available within the pool.
  • 3. Re: How to close connections physically in UCP
    rp0428 Guru
    Currently Being Moderated
    >
    The connection are getting successfully physcially closed by finding the no of available connections, borrowing each individual connection, setting them to invalid and closing the connection. (as in documentation)
    How can we close the connection(s) which are currently in use (borrowed) ? Is it the right way to cache references of all the connections either borrowed or available within the pool ?
    If all the connections are available, all connections can be physically closed irrespective of being borrowed or available within the pool.
    >
    I guess I'm still not clear on what your problem or question is.

    When pools are used a 'close' only closes the connection logically, not physically. The pool itself handles the physical closing.

    The use of 'OracleConnectionCacheImpl' which you mention in your original post has been deprecated but the 'close' method also closed the logical connection, not the physical one, and returns the connection to the pool.

    See JDBC Dev Guide
    http://docs.oracle.com/cd/B28359_01/java.111/b31224/concache.htm
    >
    Note:

    The previous cache architecture, based on OracleConnectionCache and OracleConnectionCacheImpl, is deprecated. Oracle recommends that you take advantage of the new architecture, which is more powerful and offers better performance.
    >
    Can you try to explain your problem a different way? Perhaps with an example?
  • 4. Re: How to close connections physically in UCP
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    630464 wrote:
    At this stage, if too many connections are available, it affects the system performance. Is there any way to physically close the connections ?
    The pool does whatever the pool does. It is configured in whatever way it supports.

    If you don't like that then you don't use the pool.

    But I would suspect it does allow what you want. You can start at the following location and/or look at other options on the same page/

    http://docs.oracle.com/cd/E11882_01/java.112/e12265/optimize.htm#CFHDGJGG

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points