KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In one of the interviews that I faced,I was asked to implement connection pooling. So approach was this: Create a List or HashMap Create predefined number of connections Add them to the collection. Now when the ConnectionImpl getConnection() method of ConnectionPoolingImpl class is invoked return a connection reference. Now when someone returns the connection ( releaseConnection(ConnectionImpl O) ) how can I ensure that when the same application again tries to reuse the connection object, my implementation throws an exception? The same connection object might have been returned to a new application and that should be able to use it. My point of view would be to maintain a flag variable in another array kind of structure for each Connectionimpl object and set that variable to a valid value. When user returns the connection object I would make that some invalid value. For every operation in my ConnectionImpl , I will have to verify if the user had a valid flag. What would you say to that approach?
Tags (comma-separated)
Save Edits
Cancel