In one of our application we have online security trading which is quiet
similar to ur's. In this we are making a connection to corba ( which in turn
to tuxedo -> Cpp-Oracle) ( in ur case u can do it with JDBC ) in init method
of our Login.java . We have kept one member attribute of type class
Connection. Connection to corba/JDBC is kept in this attribute. Make a
function on Login class which returns the same connection object after
validating its existance. Now when ever u call any other servlet in which u
need a connection to data base, in that servlets doGet/doPost get the same
connection object from the login class by calling the function defined on
Login class. In this way u can use this single connection object in every
servlet.
Now if a new user makes a connection the same connection object is returned
to him/her also as we had made it the init of Login and init function is
called only for the first time servlet loaded in webserver. It should work
fine as long as no of users in not very high.
Ashish
----- Original Message -----
From: Rafael Cede�o <[EMAIL PROTECTED]>; Rafael Cede�o
<[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 07, 2000 7:19 AM
Subject: Re: servlets to database connection
>
> From: Rafael =?iso-8859-1?q?Cede=F1o?= <[EMAIL PROTECTED]> on
> 12/06/2000 09:49 PM AST
>
> Please respond to "A mailing list for discussion about Sun Microsystem's
> Java Servlet API Technology." <[EMAIL PROTECTED]>
>
> To: [EMAIL PROTECTED]
> cc:
> Subject: Re: servlets to database connection
>
>
> Try using a connection pool, you can get a good example in the book
> "Professional Java Server" from Wrox.
>
> good luck!
>
> ----- Original Message -----
> From: A.R.Karthikeyan <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, December 07, 2000 9:19 AM
> Subject: servlets to database connection
>
>
> > Hi everybody,
> > I've developed a site entirely on servlets and the first page is the
> login
> > page generated by a servlet,where a connection to the Access database is
> > established during the init lifecycle of the servlet,so when there are
> > several users logging on to this site a database connection is already
> > achieved and so it leads to faster verification of the login details.I
> have
> > not closed this connection anywhere in this servlet.
> > If the login is successful ,then a session is created for every user so
> that
> > he can traverse accross the other pages of the sites where by each and
> every
> > page is generated by a separate servlet program.
> > Some of these pages consist of form fields which need to be saved in the
> > Access database.
> > My question is should I establish a connection in the init event of each
> of
> > the servlets that generate HTML pages with connectivity to the database
> or
> > since a connection to the database has already been achieved by the
> servlet
> > which generated the login page (& not yet closed ),so can i use the same
> > connection object that pertains to the first servlet in my remaining
> > servlets to make updates to the database.
> > Looking forward to some help from you.
> > Thanks in advance
> > Karthikeyan A.R
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html