Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to create a method in java class that can
1)shrinking the connection in pool after use,
2)rename the connection name
Posted
Comments
Sergey Alexandrovich Kryukov 10-Oct-11 15:20pm    
Shrinking the connection? What is "renaming the name". Does it mean the name itself has a name to be modified? :-)
--SA
nazila24 10-Oct-11 20:35pm    
yes , shrinking a connection pool.
Renaming the connection name to make easier for programmer identified the connection. Recently the connection name quiet difficult to identify
Nagy Vilmos 11-Oct-11 6:06am    
Either reality is broken or your question makes no sense.
I'm going with the later.

1 solution

A idle connection in a pool is a connection that is not being used.
To remove idle connections from a pool the following concepts are used/
1. Time connection is idle
2. A minimum number to keep even if idle.
3. The time that a connection was last used is kept.
4. Whether a connection is currently in use.

If one creates their own pool then they create a thread/timer which when fired checks the idle time (current time minus last time used) and removes (closes) connections that have been idle too long. That is repeated until the minimum is reached.

If one is using another pool then the same idea applies except one looks to the configuration of the pool.

As for the 'name', a pool should only be associated with a single location. There is no point in keeping track of individual connections (although an int is suitable.) The pool itself might have a name but that is dependent on the implementation of the pool.
 
Share this answer
 
Comments
nazila24 23-Oct-11 22:21pm    
what is time connection idle?can you give an example
jschell 24-Oct-11 13:54pm    
A idle connection is one that is not being used.
The idle time is the time based on "current time" - "last time used"
nazila24 25-Oct-11 1:27am    
in your opinion, what should i do to enable shrinking of connection?
jschell 25-Oct-11 13:50pm    
You haven't specified whether you have your own library or are using an existing one.

You also haven't specified why you think it is necessary to discard idle connections.
nazila24 26-Oct-11 20:56pm    
yes, i'm using existing one..i have try to modify it. don't you think it necessary?actually i'm a student,i have get a task to modify connection pool manager(DBAccess class) in order to improved performance and flexibility to handle the connection

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900