Establishing the connection to the database takes a long time(thinking in
"computer dimensions"). A connection pool provides a number of open
connections, which are already established. You just grab the connection
when you need it and pass it back afterwards. This is much faster. The pool
cares about timeouts, etc.
// catch a reference to the pool (singleton!) in the init-method
connectionPool = ConnectionPool.getInstance();
// get a connection (e.g. in the doPost-method)
Connection con;
con = connectionPool.getConnection();
// use it
Statement stmt;
ResultSet queryResult;
stmt = con.createStatement();
...
// finally close it
connectionPool.close(con);
Connection pooling is described in the book "Java servlets" by Karls Moss,
think he has also a website.
Mario
> Having searched the archives and nothing really helping me I was
> wondering if people out there could help me.
> I have looked at a couple of examples of connection pools but I don't
> understand them exactly, or how I could use them for servlets that I'm
> developing.
> Is there anywhere that explains connection pools in plain English as I
> am fairly new to programming and don't understand all the concepts and
> terms.
> Currently in use at the moment - user types in username and password
> and then the servlet makes the connection, this servlet then passes
> the username and password to the next servlet. So a new connection is
> made every servlet but the user only has to type in their username and
> password once.
> Basically I have a web site that allows users to update a database,
> what is the best approach, i.e.
> A connection pool - if anyone has any examples of this working
please
> could you send me them or the URL
> Connection to the database for every servlet - currently in use at
> the moment
> If anyone could suggest anything I would be very grateful.
> Cheers
> Sam Rose
>
___________________________________________________________________________
> 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