A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
Originally posted by John Meyers:
Use a set of classes that will help you do all the DB work. One will get you the connection, another will execute queries etc. That way you increase cohesion
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
what do you mean by cohesion ?
so i shouldn't write databse connection steps inside a servlet
Originally posted by Scott Johnson:
Your business logic or database code would go in the model.
[ October 05, 2006: Message edited by: Scott Johnson ]
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
if who i am is what i have, and what i have is lost, then who am i?<br /> <br />SCJP 5.0<br />SCWCD 1.4<br />SCBCD preparing
so model means bean
but bean has got setters and getters if i write the connection there how can i use bean
Originally posted by Scott Johnson:
[Dinuka] it would be much better if you put a servletcontextlistener and in the contextInitialized() method you can get the DB connection
If I understand what you are saying, you'll be creating a single database connection for use by all requests. That isn't thread-safe and definitely won't scale.
As Rahul mentioned, Saikrishna is better off using a connection pool.
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
i am creating 10 connections
the reason why i am not using connection poolin is i dont have exact usage of connection pooling and it some times gives exceptions
A = HARDWORK B = LUCK/FATE If C=(A+B) then C=SUCCESSFUL IN LIFE else C=FAILURE IN LIFE
SCJP 1.4
i am creating 10 connections
the reason why i am not using connection poolin
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Originally Posted by Scott Johnson:
Yes, we'd be happy to correct you!
Tomcat does include a connection pool library. It's based on the Jakarta-Commons DBCP. See the Tomcat User Guide section 9 for how to configure it.
please tell me that you are not creating a new connection for every sql you run
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Richard Robbins
My technology blog: TheTechnologyVault.com
My handbook for prosperity website: Prosperopedia.com
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |