Re: Updated Docs for Tomcat 4

2001-09-10 Thread Fernando_Salazar


Connection-pooling based on the Tyrex stuff is straightforward.  If you do
the Tyrex install and resource setup as
indicated in the new doc, you already have everything needed to do basic
connection pooling. Below is the code
from the new doc, modified:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup(java:comp/env);
DataSource ds = (DataSource)envCtx.lookup(jdbc/EmployeeDB);

Connection conn;

if ( dataSrc instanceof ConnectionPoolDataSource )
{
 ConnectionPoolDataSource poolDataSrc
= (ConnectionPoolDataSource)dataSrc;
 PooledConnection pc = poolDataSrc.getPooledConnection();

 conn = pc.getConnection();
}
else
{
 conn = ds.getConnection();
}

... use this connection to access the database ...
conn.close();


Again, in the default Tyrex config, the DataSource you get will have the
concrete class tyrex.jdbc.xa.XADataSourceImpl,
which implements ConnectionPoolDataSource.

I suggest you do all this in an init(), and use a static or singleton to
manage the data-source retrieved via JNDI --
don't do the JNDI lookup every time you need a connection.

When you use Tyrex like this, a background thread is created that will
close unused connections every 10 secs or so.
The pool therefore stays close to the minimum required size at all times,
but if your DB takes a long time to
establish connections, you'll experience delays when there is a spike in
activity.  If you want more control over how the
pool is managed, I suggest you look into, for example, Poolman
(http://www.codestudio.com/).

- Fernando




   

Rick Mann  

rmann@latency   To: [EMAIL PROTECTED], 
Craig R. McClanahan [EMAIL PROTECTED], tomcat user
zero.com jakarta.apache.org 
[EMAIL PROTECTED] 
 cc: (bcc: Fernando Salazar/CAM/Lotus) 

09/09/2001   Subject: Re: Updated Docs for Tomcat 4

09:50 PM   

Please respond 

to tomcat-dev  

   

   





on 9/5/01 9:04 PM, Craig R. McClanahan at [EMAIL PROTECTED] wrote:

 Things still on the TODO list:

 * Configuration instructions for populating the JNDI context that
 is provided to web applications (such as connection pools).

Erg...ack...grr! I looked at the latest docs up there...so close! I really
want to know how to make connection pools!

Anyway, keep it up. It's coming together.

Thanks!


Roderick Mann   rmann @ latencyzero.com.sansspam









Updated Docs for Tomcat 4

2001-09-05 Thread Craig R. McClanahan

I've just posted an update on the documentation that will be included in
the Tomcat 4.0 final release.  This is available online at:

http://jakarta.apache.org/tomcat/tomcat-4.0-doc-exp/

Highlights of the recent additions to the documentation include:

* Server Configuration Reference is nearly complete (only a few
  more missing pages).

* Class Loader HOW-TO explains how the class loaders in Tomcat 4
  are implemented, and where you should put your classes to make
  them available to web applications.

* Manager HOW-TO documents the use of the Manager web application
  for dynamically deploying and undeploying web applications
  without restarting Tomcat.

* Realm HOW-TO document for the three standard Realm implementations
  (JDBCRealm, JNDIRealm (!), and MemoryRealm).

Things still on the TODO list:

* Configuration instructions for populating the JNDI context that
  is provided to web applications (such as connection pools).

* Configuration of the built-in servlets provided with Tomcat 4
  that are configured from $CATALINA_HOME/conf/web.xml.

* Configuration of the mod_webapp connector (in the same style as
  the rest of the Tomcat 4 docs).

* Other things that people tell us are still missing -- but it's
  more likely to get done if you offer actual documents instead
  of just suggestions :-)


Craig McClanahan