| Author |
Interview question - Connection Pool
|
Timothy Sam
Ranch Hand
Joined: Sep 18, 2005
Posts: 746
|
|
Hi guys I came from a very depressing interview yesterday(It felt like the interviewer didn't like my answer). Anyway, the question was "How will you do connection pooling in a Servlet". I had an answer, the first thing that came into my mind was that there was a connection pool mechanism in tomcat. But he wasn't satisfied to he insisted on how will I do it in a Servlet. I didn't know the exact steps (but I swear it was in the back of my mind). So the help I'm asking you now is... How will you answer this question in let's say... No more than a minute? Thanks!
|
SCJP 1.5
http://devpinoy.org/blogs/lamia/ - http://everypesocounts.com/
|
 |
Mark Herschberg
Sheriff
Joined: Dec 04, 2000
Posts: 6037
|
|
Um. maybe I'm getting rusty but my answer would be... I wouldn't put a connection pool in a servlet; it breaks the model. The connection pool should be done by by the container. --Mark
|
 |
Timothy Sam
Ranch Hand
Joined: Sep 18, 2005
Posts: 746
|
|
Thanks Yeah, your suggestion makes sense. It shouldn't be in a Servlet(thus, my idea that tomcat has a built-in mechanism). I guess I wasn't able to answer well because of the time pressure. There were lots of applicants there. Thanks again!
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
I'm not sure if I'd want to work for a person that would put connection pooling in a Servlet. How do you access a connection from a pool in a Servlet? That's a valid question. But a pooling mechanism should be factored out into a separate service a variety of resources could access. -Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
Originally posted by Cameron McKenzie: I'm not sure if I'd want to work for a person that would put connection pooling in a Servlet. How do you access a connection from a pool in a Servlet? That's a valid question. But a pooling mechanism should be factored out into a separate service a variety of resources could access. -Cameron McKenzie
Yes, but if some one forces you to answer the question, they might want to rephrase it. Like, where would you acquire and release connections in a servlet if the container does not give you a mechanism to pool connections. Either way interviews can be really hard on you sometimes. Dont be so hard on yourself. It happens. Next time try to relax.
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Srikanth Basa
Ranch Hand
Joined: Jun 06, 2005
Posts: 241
|
|
Originally posted by Timothy Sam: How will you answer this question in let's say...
I know one of my friends working on a project, which uses a proprietary framework on top of servlets and they have written their own custom connection pooling mechanism. I am not aware what forced them to write it by themselves but I guess the interviewer was looking for this kind of answer.
|
 |
Timothy Sam
Ranch Hand
Joined: Sep 18, 2005
Posts: 746
|
|
|
It could've been better if he asked me to explain the concept of connection pooling! Lolz!
|
 |
Srikanth Basa
Ranch Hand
Joined: Jun 06, 2005
Posts: 241
|
|
Perhaps there is nothing you can do in situations when the interviewer has something specific in mind but fails to express it. As you said, he could have asked the you to explain connection pooling but as this is a very common question, he might have tried to come up with some creative question but failed successfully in framing it  [ October 29, 2007: Message edited by: Srikanth Basavaraju ]
|
 |
arulk pillai
Author
Ranch Hand
Joined: May 31, 2007
Posts: 3190
|
|
Probably the interviewer was expecting the answer that it is not a best practice to have a connection pool in the servlet. SOme interviewrs ask tricky questions like this to perplex the candidate. For example What is the "const" keyword used for etc. [ October 29, 2007: Message edited by: arulk pillai ]
|
Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
|
 |
Billy Tsai
Ranch Hand
Joined: May 23, 2003
Posts: 1297
|
|
|
do not reinvent the wheel
|
BEA 8.1 Certified Administrator, IBM Certified Solution Developer For XML 1.1 and Related Technologies, SCJP, SCWCD, SCBCD, SCDJWS, SCJD, SCEA,
Oracle Certified Master Java EE 5 Enterprise Architect
|
 |
Ajay Saxena
Ranch Hand
Joined: Nov 13, 2006
Posts: 154
|
|
A relevant article http://www.webdevelopersjournal.com/columns/connection_pool.html
|
 |
 |
|
|
subject: Interview question - Connection Pool
|
|
|