Citigroup Interview Question
Financial Software DevelopersCountry: United States
One thing to remember when writing connection-pools: never pass the raw connection to your caller. Put it in a wrapper object that has no-ops for calls like close() //connection, so that the raw connection is protected, and pass it via interface. When a connectionWrapper is returned by user, put the raw connection back in your pool, but also null out the reference from the wrapper to the raw-connection. Also good idea would be to rollback any uncommited transactions on the raw connection before putting it in pool
Below is the connection pooling at the most basic level(for database connections ). One can easily put pool size and time out in it. To give the user the flexibility to use close method on connection we will have to provide a wrapper for connection and implement several methods.
- praveenkcs28 April 20, 2013