• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dtabase connection in servlets

 
renu richard
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new bie to JSP/Servlets. I have seen most of the times that in order to make a database connection, servlet will call a java class which will have the code for making databasse connection..

Is this is the standard way of writing the code??.. I have this query because, if this is the case,, then each time a request comes to servlet each time this code runs to make a database connection. Is it not performance issue ??? Please share your thoughts on this...Thanks


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
renu richard wrote:Is this is the standard way of writing the code??..

yes

renu richard wrote:
I have this query because, if this is the case,, then each time a request comes to servlet each time this code runs to make a database connection. Is it not performance issue ???


because keeping only one connection object for all user is bad. if you think about performance then you can implement Connection Pooling .
 
dimpsonu arora
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
renu richard wrote:
Hi,

I am new bie to JSP/Servlets. I have seen most of the times that in order to make a database connection, servlet will call a java class which will have the code for making databasse connection..

Is this is the standard way of writing the code??.. I have this query because, if this is the case,, then each time a request comes to servlet each time this code runs to make a database connection. Is it not performance issue ??? Please share your thoughts on this...Thanks




Hi Richard,

You can try some frameworks like spring & struts which will help you db connections and mauplation better.

They make code writting/handling easy.

Jatin
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dimpsonu arora wrote:
You can try some frameworks like spring & struts which will help you db connections and mauplation better.


In what way they are helping to get DB Connection?.... Even Struts you need Database utility Classes to get DB Connection
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!