How can I avoid ResourceExceptions when sending more requests for database connections from the pool than are currently available?

Submitted by: Administrator
The fundamental problem is too few resources (database connections in the connection pool) for the work load. The correct response is to increase the maximum number of connections in the connection pool. Optimally designed applications only require the server to have one pool connection per execute thread.
The proper application response to a resource exception is not to retry the request in a tight loop, which would tie up execute threads on the server.
You should design your application to gracefully fail if no connections are available. Try to ensure that you get the connection as late as possible in your application code and return them to the pool as early as possible so that you do not see as many NoResource exceptions. It is better to have the connection as a method level variable and close the connection in a finally block as in the following example:

try{
...
} catch(Exception handleEx) {
...
} finally {
try{ conn.close();
}catch (Exception ignore){} // always return the connection to pool
}
Submitted by: Administrator

Read Online BEA Weblogic Job Interview Questions And Answers