This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interview question - Connection Pool

 
Timothy Sam
Ranch Hand
Posts: 751
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Mark Herschberg
Sheriff
Posts: 6037
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 751
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Srikanth Basa
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 751
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It could've been better if he asked me to explain the concept of connection pooling! Lolz!
 
Srikanth Basa
Ranch Hand
Posts: 241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Billy Tsai
Ranch Hand
Posts: 1304
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do not reinvent the wheel
 
Ajay Saxena
Ranch Hand
Posts: 154
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic