You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/10/19 14:13:53 UTC

svn commit: r1186143 - in /tomcat/tc7.0.x/trunk: ./ webapps/docs/jndi-datasource-examples-howto.xml

Author: kkolinko
Date: Wed Oct 19 12:13:52 2011
New Revision: 1186143

URL: http://svn.apache.org/viewvc?rev=1186143&view=rev
Log:
Merged revisions r1186123, r1186137 from tomcat/trunk:
Correct the markup. s/db/database/
Rearranged the introductory section for DBCP pool.
Removed mention of JVM 1.4.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 19 12:13:52 2011
@@ -1 +1 @@
-/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104
+/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137

Modified: tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml?rev=1186143&r1=1186142&r2=1186143&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/jndi-datasource-examples-howto.xml Wed Oct 19 12:13:52 2011
@@ -108,69 +108,77 @@ a <code>ServletContextListener</code>.
 
 <section name="Database Connection Pool (DBCP) Configurations">
 
-<p>DBCP provides support for JDBC 2.0.  On systems using a 1.4 JVM DBCP
-will support JDBC 3.0. Please let us know if you have used DBCP and its
-JDBC 3.0 features with a 1.4 JVM.
+<p>The default database connection pool implementation in Apache Tomcat
+relies on the libraries from the
+<a href="http://commons.apache.org/">Apache Commons</a> project.
+The following libraries are used:
 </p>
 
-<p>See the <a href="http://commons.apache.org/dbcp/configuration.html">
-DBCP documentation</a> for a complete list of configuration parameters.
-</p>
-
-<subsection name="Installation">
-<p>DBCP uses the Commons Database Connection Pool. It relies on
-number of Commons components:
 <ul>
 <li>Commons DBCP</li>
 <li>Commons Pool</li>
 </ul>
+
+<p>
 These libraries are located in a single JAR at 
 <code>$CATALINA_HOME/lib/tomcat-dbcp.jar</code>. However,
 only the classes needed for connection pooling have been included, and the
 packages have been renamed to avoid interfering with applications.
 </p>
 
+<p>DBCP 1.4 provides support for JDBC 4.0.</p>
+
+<subsection name="Installation">
+
+<p>See the <a href="http://commons.apache.org/dbcp/configuration.html">
+DBCP documentation</a> for a complete list of configuration parameters.
+</p>
+
 </subsection>
 
-<subsection name="Preventing dB connection pool leaks">
+<subsection name="Preventing database connection pool leaks">
 
 <p>
 A database connection pool creates and manages a pool of connections
 to a database. Recycling and reusing already existing connections
-to a dB is more efficient than opening a new connection.
+to a database is more efficient than opening a new connection.
 </p>
 
 <p>
 There is one problem with connection pooling.  A web application has
 to explicitly close ResultSet's, Statement's, and Connection's.
 Failure of a web application to close these resources can result in
-them never being available again for reuse, a db connection pool "leak".
-This can eventually result in your web application db connections failing
+them never being available again for reuse, a database connection pool "leak".
+This can eventually result in your web application database connections failing
 if there are no more available connections.</p>
 
 <p>
-There is a solution to this problem.  The Jakarta-Commons DBCP can be
+There is a solution to this problem.  The Apache Commons DBCP can be
 configured to track and recover these abandoned dB connections.  Not
 only can it recover them, but also generate a stack trace for the code
 which opened these resources and never closed them.</p>
 
 <p>
-To configure a DBCP DataSource so that abandoned dB connections are
+To configure a DBCP DataSource so that abandoned database connections are
 removed and recycled add the following attribute to the
 <code>Resource</code> configuration for your DBCP DataSource:
-<source>
-            removeAbandoned="true"
-</source>
-When available db connections run low DBCP will recover and recycle
-any abandoned dB connections it finds. The default is <code>false</code>.
+</p>
+
+<source>removeAbandoned="true"</source>
+
+<p>
+When available database connections run low DBCP will recover and recycle
+any abandoned database connections it finds. The default is <code>false</code>.
 </p>
 
 <p>
 Use the <code>removeAbandonedTimeout</code> attribute to set the number
 of seconds a dB connection has been idle before it is considered abandoned.
-<source>
-            removeAbandonedTimeout="60"
-</source>
+</p>
+
+<source>removeAbandonedTimeout="60"</source>
+
+<p>
 The default timeout for removing abandoned connections is 300 seconds.
 </p>
 
@@ -178,9 +186,9 @@ The default timeout for removing abandon
 The <code>logAbandoned</code> attribute can be set to <code>true</code>
 if you want DBCP to log a stack trace of the code which abandoned the
 dB connection resources.
-<source>
-            logAbandoned="true"
-</source>
+</p>
+<source>logAbandoned="true"</source>
+<p>
 The default is <code>false</code>.
 </p>
 
@@ -189,13 +197,14 @@ The default is <code>false</code>.
 <subsection name="MySQL DBCP Example">
 
 <h3>0. Introduction</h3>
-<p>Versions of <a href="http://www.mysql.com/products/mysql/index.html">MySQL</a> and JDBC drivers that have been reported to work:
+<p>Versions of <a href="http://www.mysql.com/products/mysql/index.html">MySQL</a> and JDBC
+drivers that have been reported to work:
+</p>
 <ul>
 <li>MySQL 3.23.47, MySQL 3.23.47 using InnoDB,, MySQL 3.23.58,  MySQL 4.0.1alpha</li>
 <li><a href="http://www.mysql.com/products/connector-j">Connector/J</a> 3.0.11-stable (the official JDBC Driver)</li>
 <li><a href="http://mmmysql.sourceforge.net">mm.mysql</a> 2.0.14 (an old 3rd party JDBC Driver)</li>
 </ul>
-</p>
 
 <p>Before you proceed, don't forget to copy the JDBC Driver's jar into <code>$CATALINA_HOME/lib</code>.</p>
 
@@ -207,6 +216,7 @@ Ensure that you follow these instruction
 <p>Create a new test user, a new database and a single test table.
 Your MySQL user <strong>must</strong> have a password assigned. The driver
 will fail if you try to connect with an empty password.
+</p>
 <source>
 mysql&gt; GRANT ALL PRIVILEGES ON *.* TO javauser@localhost 
     -&gt;   IDENTIFIED BY 'javadude' WITH GRANT OPTION;
@@ -221,9 +231,9 @@ mysql&gt; create table testdata (
 <strong>Note:</strong> the above user should be removed once testing is
 complete!
 </blockquote>
-</p>
 
 <p>Next insert some test data into the testdata table.
+</p>
 <source>
 mysql&gt; insert into testdata values(null, 'hello', 12345);
 Query OK, 1 row affected (0.00 sec)
@@ -238,13 +248,11 @@ mysql> select * from testdata;
 
 mysql&gt;
 </source>
-</p>
 
 <h3>2. Context configuration</h3>
 <p>Configure the JNDI DataSource in Tomcat by adding a declaration for your
 resource to your <a href="config/context.html">Context</a>.</p>
-<p>For example:
-
+<p>For example:</p>
 <source>
 &lt;Context&gt;
 
@@ -280,11 +288,10 @@ resource to your <a href="config/context
 
 &lt;/Context&gt;
 </source>
-</p>
 
 <h3>3. web.xml configuration</h3>
 
-<p>Now create a <code>WEB-INF/web.xml</code> for this test application.
+<p>Now create a <code>WEB-INF/web.xml</code> for this test application.</p>
 <source>
 &lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -300,7 +307,6 @@ http://java.sun.com/xml/ns/j2ee/web-app_
   &lt;/resource-ref&gt;
 &lt;/web-app&gt;
 </source>
-</p>
 
 <h3>4. Test code</h3>
 <p>Now create a simple <code>test.jsp</code> page for use later.
@@ -375,6 +381,7 @@ not the same as the tnsname). The schema
 user scott.</p>
 
 <p>Use of the OCI driver should simply involve a changing thin to oci in the URL string.
+</p>
 <source>
 &lt;Resource name="jdbc/myoracle" auth="Container"
               type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
@@ -382,7 +389,6 @@ user scott.</p>
               username="scott" password="tiger" maxActive="20" maxIdle="10"
               maxWait="-1"/&gt; 
 </source>
-</p>
 
 <h3>2.    web.xml configuration</h3>
 <p>You should ensure that you respect the element ordering defined by the DTD when you
@@ -578,13 +584,13 @@ Change the database connect string (of t
 <p>Here are some common problems encountered with a web application which
 uses a database and tips for how to solve them.</p>
 
-<subsection name="Intermittent dB Connection Failures">
+<subsection name="Intermittent Database Connection Failures">
 <p>
 Tomcat runs within a JVM.  The JVM periodically performs garbage collection
 (GC) to remove java objects which are no longer being used.  When the JVM
 performs GC execution of code within Tomcat freezes. If the maximum time
-configured for establishment of a dB connection is less than the amount
-of time garbage collection took you can get a db conneciton failure.
+configured for establishment of a database connection is less than the amount
+of time garbage collection took you can get a database connection failure.
 </p>
 
 <p>To collect data on how long garbage collection is taking add the
@@ -610,6 +616,7 @@ connection just returns it to the pool f
 it doesn't close the connection.  And Tomcat uses multiple threads to
 handle concurrent requests. Here is an example of the sequence
 of events which could cause this error in Tomcat:
+</p>
 <pre>
   Request 1 running in Thread 1 gets a db connection.
 
@@ -629,8 +636,10 @@ of events which could cause this error i
   Request 2 Thread 2 tries to use the db connection but fails
   because Request 1 closed it.
 </pre>
-Here is an example of properly written code to use a db connection
+<p>
+Here is an example of properly written code to use a database connection
 obtained from a connection pool:
+</p>
 <pre>
   Connection conn = null;
   Statement stmt = null;  // Or PreparedStatement if needed
@@ -665,7 +674,6 @@ obtained from a connection pool:
     }
   }
 </pre>
-</p>
 
 </subsection>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org