Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test 483 - Test Question

 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
This is a question from the pre-assessment test:
Question 21)
A developer is using a DBConnectionPool to work with a database. While running, a DBException is thrown. What are possible causes?

a)The pool has reached its maximum number of connections and cannot create more.
b)No maximum was specified for the pool
c)The pool needs to be reinitialized
d)The pool was not initialized

Single Select - Please select the best answer (one and only one choice must be selected).
The correct answer is A. But why?
Why are the others wrong?
Where can I find information about this topic? JDBC specification was no help.
Kind regards
Jochen
SUN Certified Programmer
IBM Certified Specialist - Visual Age 3
IBM Certified Specialist - Visual Age 4
IBM Certified Specialist - WebSphere Application Server 4
IBM Certified Specialist - DB2 UDB V7.1
IBM Certified Solutions Developer - DB UDB V7.1 Applicaton Development
[ April 11, 2002: Message edited by: Jochen ]
 
james edwin
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
See reasons are
>a) The pool has reached its maximum number of connections and cannot create more.
A is correct
>b) No maximum was specified for the pool
This makes no harm,if no maximum number r specified,then there is no limit on pool size,pool will create as many connection possible.
or it will use the default value
>c) The pool needs to be reinitialized
At no point,while pooling is running or application is running normally not recommened,it's not reinitialized.
>d) The pool was not initialized
See in question it's written,the while running.so that means pool was initialized.
I hope abv will help.
PS: Your name doesn't match with naming policy,please re-register
[ April 11, 2002: Message edited by: james edwin ]
[ April 11, 2002: Message edited by: james edwin ]
 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Thank you for the explanation!
But where do I find information about this topic?
Jochen van Waasen
 
Jochen van Waasen
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I changed my display name!
 
james edwin
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Thanks for following naming policy.For connection pool,pls search Google u will find lot of sites and once u implement connection pool,answer to your question will be cleared to you.
 
Tony Chen
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything can be found in WebSphere InfoCenter v4.0
And the specific topic about your question is 4.2.4.2.1.3: Handling data access exceptions
ConnectionWaitTimeoutException
This exception (com.ibm.ejs.cm.pool.ConnectionWaitTimeoutException) indicates that the application has waited for the connectionTimeout (CONN_TIMEOUT) number of seconds and has not been returned a connection. This can occur when the pool is at its maximum size and all of the connections are in use by other applications for the duration of the wait. In addition, there are no connections currently in use that the application can share, because either the user ID and password are different or it is in a different transaction. The following code fragment shows how to use this exception:
java.sql.Connection conn = null;
javax.sql.DataSource ds = null;
...
try {
// Retrieve a DataSource through the JNDI Naming Service
java.util.Properties parms = new java.util.Properties();
setProperty.put(Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.websphere.naming.WsnInitialContextFactory");
// Create the Initial Naming Context
javax.naming.Context ctx = new
javax.naming.InitialContext(parms);
// Lookup through the naming service to retrieve a DataSource object
javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/SampleDB");
conn = ds.getConnection();
// work on connection
}
catch (com.ibm.ejs.cm.pool.ConnectionWaitTimeoutException cw) {
// notify the user that the system could not provide a
// connection to the database
}
catch (java.sql.SQLException sqle) {
// deal with exception
}
In all cases in which the ConnectionWaitTimeoutException is caught, there is very little to do in terms of recovery. It usually doesn't make sense to retry the getConnection() method, because if a longer wait time is required, the connectionTimeout datasource property should be set higher. Therefore, if this exception is caught by the application, the administrator should review the expected usage of the application and tune the connection pool and the database accordingly.
Originally posted by Jochen:
Hi!
Thank you for the explanation!
But where do I find information about this topic?
Jochen van Waasen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic