Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-435

[PATCH] Friendly BasicDataSourceFactory

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Nightly Builds
    • 2.1
    • commons-dbcp2, Tomcat 8

    Description

      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:

      <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"/>

      But filling something wrong will output warnings to logfiles (stderr and logger):

      <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"/>

      logfile output:

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            denixx denixx baykin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: