A
apue
Hi Newsgroup,
i have written an Objectpool for Database connections. All locked
connections are stored within a Vector (called _used) and all unlocked
connections are stored within a second Vector (called _unused).
Now consider the following situation:
------------------- code ---------------------------------------
DbConnectionPool pool = new DbConnectionPool( driver, url, user, passwd);
Connection dbcon = pool.getConnection();
int sizeUsed = pool.getUsed(); // returns 1, thats ok
// ...
// ... lets do some actions with dbcon ....
// ...
// ... programmer does not notice
// ... that dbcon is still in use.
// ... so he checks out a new connection
//
dbcon = pool.getConnection();
sizeUsed = pool.getUsed(); // return 2, uppps!!!
------------------- code ---------------------------------------
Because the programmer checks out a new connections, two database
connections are now marked as _used.
Is there any possibility to avoid such situations?
Thank you in advance
mike
i have written an Objectpool for Database connections. All locked
connections are stored within a Vector (called _used) and all unlocked
connections are stored within a second Vector (called _unused).
Now consider the following situation:
------------------- code ---------------------------------------
DbConnectionPool pool = new DbConnectionPool( driver, url, user, passwd);
Connection dbcon = pool.getConnection();
int sizeUsed = pool.getUsed(); // returns 1, thats ok
// ...
// ... lets do some actions with dbcon ....
// ...
// ... programmer does not notice
// ... that dbcon is still in use.
// ... so he checks out a new connection
//
dbcon = pool.getConnection();
sizeUsed = pool.getUsed(); // return 2, uppps!!!
------------------- code ---------------------------------------
Because the programmer checks out a new connections, two database
connections are now marked as _used.
Is there any possibility to avoid such situations?
Thank you in advance
mike