On 24/03/18 22:28, Shawn Heisey wrote:
<snip/>

> The factory we have now is
> "org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory".  The factory in
> the documentation, and what I put in the configuration I'm building, is
> "org.apache.tomcat.jdbc.pool.DataSourceFactory". These are both in the
> tomcat package space.  Yet you're telling me that I'm not using the
> Tomcat pool.  How is anybody supposed to come to that conclusion on
> their own?
> 
> If the attributes on that page cannot be used with
> "org.apache.tomcat.jdbc.pool.DataSourceFactory" ... then why are they
> included on a page that says to use that factory?

There are two pools available.

You use the factory to choose between them.

org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory is a package renamed
(to avoid conflicts) exact copy of Commons DBCP. For 7.0.42 that will be:
- Commons DBCP 1.4
- Commons Pool 1.5.7

org.apache.tomcat.jdbc.pool.DataSourceFactory is a different pool
developed in the Tomcat project (generally called JDBC pool).

The default factory if you do not specify one is
org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory


Which factory you want to use is up to you. Generally,

Commons DBCP 1.x was slow compared JDBC pool to in highly concurrent
environments. I suspect this isn't an issue for most users.

Commons DBCP 1.x is provides more features and enables more of them by
default.

As of Tomcat 8 DBCP 2.x is used which addresses the performance issues.

Generally, I'd recommend DBCP unless you need a feature that is only
available in JDBC pool.

> By the way, the 9.0 version of the docs still says virtually the same
> thing.  I found a historical document using Google for the 7.0.42
> version we're running, and it ALSO has virtually the same information on
> it.
> 
> Since I can't rely on the documentation, can somebody please give me a
> configuration that will do what I'm trying to do?  And explain each
> difference from the config that I built, or point me to documentation
> that's complete enough for me to figure it out on my own?

You need to make sure you are using the docs for the pool you want to
use. There are minor differences between Commons DBCP and JDBC pool and
also differences over time.

The source for the DBCP 1.4 docs is here:
https://github.com/apache/commons-dbcp/blob/DBCP_1_4/xdocs/configuration.xml

The source for JDBC pool docs as of Tomcat 7.0.42 is here:
https://svn.apache.org/viewvc/tomcat/tc7.0.x/tags/TOMCAT_7_0_42/modules/jdbc-pool/doc/jdbc-pool.xml?view=annotate


Regarding your configuration:
<Resource
name="jdbc/REDACTED"
auth="Container"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
type="javax.sql.DataSource"
maxActive="60"
maxIdle="10"
maxWait="30000"
removeAbandoned="true"
removeAbandonedTimeout="30"
username="REDACTED"
password="REDACTED"
testOnBorrow="true"
validationQuery="select 1"
url="jdbc:mysql://REDACTED.REDACTED.com:3306/REDACTED?autoReconnect=true&amp;zeroDateTimeBehavior=round"
/>

Generally, that looks OK but I'd strongly recommend that you use
"autoReconnect=false" in the URL. autoReconnect is known to be
problematic with connection pools.

The removeAbandonedTimeout looks low but if all the queries are expected
to be well under 30s then that should be OK.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to