This is great. But do you have to hardcode your username and passwd inside
your caller code or  is it passed by  third party or got from a
configuration file at startup?

Bing

At 10:41 AM 6/11/99 +0200, you wrote:
>Hi
>Let me specify a similar (more general) scenario:
>Suposse a servlet-based application without several entry points.
>There isn't an unique initial point, so you can't initialize the DBPool,
or others
>common resources,
>in a particular servlet. Each servlet is able to manage the users by some
kind of
>session management,
>or authentication.
>
>In this context, we use the following aproach to solve the problem (DBPool
>initialization).
>The DBPool class, has a Hashtable with the active pools.
>This class has a methods like:
>
>   public static Connection getConnection(String user, String password){
>   }
>
>or more sophisticated:
>
>   public static Connection getConnection(String user, String password,
String
>jdbc_driver, int number_of_connections)
>
>The returned connection is binded to the proper DBPool by another
Hashtable, so
>may be released with
>a method like:
>
>public static void release(Connection conn){
>    // which DBPool is binded with this connection?
>    DBPool pool = hash_connections_dbpools.get(conn);
>   // mark the connection as ready for a new request
>   pool.hash_locked.remove(conn):
>   pool.hash_unlocked.put(conn, new Long(System.currentTimeMillis())):
>}
>
>(The currentTimeMillis can be used by a cleaner thread that release
connections
>after a long time,
>as a prevention from unreleased connections)
>
>When a servlet (or whatever) claim for a connection of a pool, the DBPool
class
>checks if
>there are a created pool with the specified
>user/password/jdbc_driver/number_of_connetcions...
>and is created if necessary.
>Then return an available connection of that pool.
>You can also specify a default number of connections, JDBC driver, ..., so
the
>client doesn't see the pool,
>just a connection (the goal here is encapsulation).
>
>In this way there is no need for a ServletContext, or preloading servlets.
>
>Any idea are wellcome.
>
>Bing Zhang wrote:
>
>> I just found out that servletrunner can not preload a servlet. I am using
>> the servletrunner to test my application. If you only use servletrunner to
>> test your application, the way to get around is in your calling code you
>> call the servlet you want to preload first.
>>
>> Apache/Jserv has the capability to preload the servlet.
>>
>> Bing
>>
>> At 12:06 PM 6/10/99 +0200, you wrote:
>> >How do you preload a servlet ??? (I'm using the jsdk2.1 servletrunner)
>> >
>> >> How about construct a faceless servlet,i.e. GenericSerlet, preload it
and
>> >> initialize the connection pool and store it as a static member of a
class.
>> >> The subsequent servlet just call a method of this class, be it static or
>> >> non static. In this case you do not need ServletContext.
>> >>
>> >> Bing
>> >>
>> >> At 08:41 PM 6/9/99 +0100, you wrote:
>> >>>What about the following:
>> >>>
>> >>>The first time DbServlet is called, get the ServletContext and assign
it to
>> >>>a static variable. Also create a public static method in DbServlet to
>> return
>> >>>the ServletContext. Any class could then retrieve the SessionContext.
>> >>>

>> >>>Not sure if this is the best way of doing it, but hope it helps.
>> >>>
>> >>>Stephen Baishya
>> >>>
>> >>>----- Original Message -----
>> >>>From: tmueller <[EMAIL PROTECTED]>
>> >>>To: <[EMAIL PROTECTED]>
>> >>>Sent: Tuesday, June 08, 1999 10:13 PM
>> >>>Subject: Connection Pooling Servlet
>> >>>
>> >>>
>> >>>> Hello all,
>> >>>>
>> >>>> Im writing a servlet (DbServlet) that uses the DbConnectionBroker as
>> >>>> explained in chapter 9 pg. 266 of the Jason Hunter (O'Reilly) book
that
>> >>>will
>> >>>> hand off connection objects.
>> >>>>
>> >>>> The problem is that the classes of another servlet cannot use
>> >>>> getServletContext() to get the reference to the DbServlet
>> >>>> since the classes have no servlet context of thier own.
>> >>>>
>> >>>> So my question is : Is there a way to get to the DbServlet with out
>> having
>> >>>> to hand out the ServletContext to every class
>> >>>> and the classes they use?
>> >>>>
>> >>>> Thanks in advance.
>
>--
>------------------------------------------------
>Manuel Hurtado Sanchez
>Telefonica Data
>Phone: +34 917548650
>Fax:   +34 917548692
>Julian Camarillo,6
>28037 Madrid, Spain.
>------------------------------------------------
>
>___________________________________________________________________________
>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

Reply via email to