denixx baykin created DBCP-435:
----------------------------------
Summary: [PATCH] Friendly BasicDataSourceFactory
Key: DBCP-435
URL: https://issues.apache.org/jira/browse/DBCP-435
Project: Commons Dbcp
Issue Type: Improvement
Affects Versions: Nightly Builds
Environment: commons-dbcp2, Tomcat 8
Reporter: denixx baykin
Priority: Critical
Fix For: Nightly Builds
I wish to make DBCP2 main component (BasicDataSourceFactory) more friendly.
This is a component which end user faces in Tomcat, when he tries to configure
DataSource in Tomcat.
I think factory should help user (in our case it is administrators) to
understand, that he make a mistake in configuration.
Tested with Tomcat 8 from trunk.
Properly configured Resource in context.xml or server.xml will leave nothing in
logs:
{code:xml}<Resource name="jdbc/MySql"
type="javax.sql.DataSource"
validationQuery="SELECT 1"
timeBetweenEvictionRunsMillis="30000"
maxTotal="20"
maxIdle="10"
minIdle="1"
maxWaitMillis="2000"
initialSize="20"
removeAbandonedTimeout="60"
removeAbandonedOnMaintenance="true"
logAbandoned="true"
minEvictableIdleTimeMillis="30000"
username="admin"
password="megapassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/new_schema"/>{code}
But filling something wrong will output warnings to logfiles (stderr and
logger):
{code:xml}<Resource name="jdbc/MySql"
auth="Container"
factory="org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory"
type="javax.sql.DataSource"
validationQuery="SELECT 1"
validationInterval="30000"
timeBetweenEvictionRunsMillis="30000"
maxActive="20"
maxIdle="10"
minIdle="1"
maxWait="20000"
initialSize="20"
removeAbandonedTimeout="60"
removeAbandoned="true"
logAbandoned="true"
minEvictableIdleTimeMillis="30000"
jmxEnabled="true"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
username="admin"
password="megapassword"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/new_schema"/>{code}
logfile output:
{noformat}13-Feb-2015 15:30:44.178 WARNING [main]
org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory.getObjectInstance WARNING!
Property maxActive is not used since DBCP2, use maxTotal instead. maxTotal
default value is 8. You have set value of "20" for "maxActive" property
WARNING! Property removeAbandoned is not used since DBCP2, use one or both of
removeAbandonedOnBorrow or removeAbandonedOnMaintenance instead. Both have
default value set to false. You have set value of "true" for "removeAbandoned"
property
WARNING! Property maxWait is not used in DBCP (it's a Tomcat JDBC pool
feature), use maxWaitMillis instead. maxWaitMillis default value is -1. You
have set value of "20000" for "maxWait" property
WARNING! Property validationInterval is not used in DBCP, it's a Tomcat JDBC
pool feature. Ignoring. You have set value of "30000" for "validationInterval"
property
WARNING! Property jdbcInterceptors is not used in DBCP, it's a Tomcat JDBC pool
feature. Ignoring. You have set value of
"org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
for "jdbcInterceptors" property
WARNING! Property jmxEnabled is not used in DBCP, it's a Tomcat JDBC pool
feature. Ignoring. You have set value of "true" for "jmxEnabled" property
INFO. Ignoring unknown property: value of "Container" for "auth" property
INFO. Ignoring unknown property: value of
"org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory" for "factory"
property{noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)