File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes ServletContextListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServletContextListener" Watch "ServletContextListener" New topic
Author

ServletContextListener

lokesh rajarathnam
Ranch Hand

Joined: May 17, 2007
Posts: 35
Hi all...

1. I writen a code for access database connection through contextlistener,




2. Attribute class


How can i achieve the availabelity of database connection for the entier application....
if i write a servlet class for access data items from tabel, their also i need connection object, statement object and more as same like Attribute class( which shown above 2).

please any one can help me how can i write a code in servlet for access a database items.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by lokesh rajarathnam:

How can i achieve the availabelity of database connection for the entier application....


You shouldn't.
Instead look into connection pooling.
All modern, spec compliant servers offer it at a container level.

What you're trying to do will give you nothing but headaches and will most likely result in a slow application.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Qussay Najjar
Ranch Hand

Joined: Jan 18, 2008
Posts: 53
Originally posted by Ben Souther:

What you're trying to do will give you nothing but headaches and will most likely result in a slow application.


you know Lokesh That's completely true, it does cause headaches,,
I'm still suffering of using that way..


Qussay NAJJAR
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ServletContextListener