Great idea, but with one snag...
The init() method is called the first time the servlet is requested, on
our site that generates the login page. The login page is what our
users use to login to our database, therefore we cannot open a
connection to the db in the init() method because the users haven't
logged in yet.
In other words, in order to establish a db connection, we need a
username and password. When init() is called that information isn't
available yet...
I guess my question is really, should I be calling
DriverManager.registerDriver() each time a user tries to obtain a
connection to the db. I realize that I need to call
Connection.getConnection() but do I need to call the registerDriver()
method as well? Or will the JVM know to use a driver that has been
"pre-registered"?
Jaman
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 28, 2000 1:54 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Multi-threaded application
If you do it in the init() method of the servlet {which will be executed
only first time the servlet is loaded} i think you will get rid of this
problem.
i.e have a static connection obj and create it in the init method of the
servlet. For each servlet req invocations, use that static connection
obj to
do the db activity. If you are doing it on a heavy trafic site then you
could also do database conn pooling.
Hope it answers your question.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 28, 2000 2:06 PM
To: [EMAIL PROTECTED]
Subject: Multi-threaded application
Hi all,
I have a question about a servlet application that I am
developing. In a multi-threaded application is it necessary to
register the JDBC drivers before each connection is made to the
database? Or is registering the JDBC driver once adequate enough?
Currently, each time a user attempts to log into our database,
the
application registers a JDBC driver, then calls getConnection using
said driver. I was wondering if I could just register 1 driver then
just call getConnection using the same driver for each login attempt.
I've looked but haven't really found much documentation about
either point and my JDBC knowledge isn't very strong.
Thanks,
Jaman Burton
[EMAIL PROTECTED]
Excel Corporation
----------------<< "[EMAIL PROTECTED]" FOOTER MESSAGE
>>---------------------
To leave list [EMAIL PROTECTED], please direct the one-line message
unsubscribe JAVA
to email address
[EMAIL PROTECTED]
If you have difficulties unsubscribing, please direct email to
[EMAIL PROTECTED]
York University, Toronto Canada
http://www.yorku.ca
Because e-mail can be altered electronically,
the integrity of this communication cannot be guaranteed.
----------------<< "[EMAIL PROTECTED]" FOOTER MESSAGE
>>---------------------
To leave list [EMAIL PROTECTED], please direct the one-line message
unsubscribe JAVA
to email address
[EMAIL PROTECTED]
If you have difficulties unsubscribing, please direct email to
[EMAIL PROTECTED]
York University, Toronto Canada
http://www.yorku.ca
___________________________________________________________________________
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