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!
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.
Joined: Sep 18, 2005
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.
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.
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.
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.
Joined: Sep 18, 2005
It could've been better if he asked me to explain the concept of connection pooling! Lolz!
Joined: Jun 06, 2005
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 ]
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 ]