Bug 58338 - BasicDataSourceFactory uses wrong attribute name
Summary: BasicDataSourceFactory uses wrong attribute name
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.64
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2015-09-07 11:01 UTC by Stephan van Hoof
Modified: 2019-03-15 23:24 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Stephan van Hoof 2015-09-07 11:01:38 UTC
According to the Tomcat 7 "JNDI Resources HOW-TO" part "JDBC resources" documentation one or more initial SQL statement(s) for each created connection can be specified using "connectionInitSqls" attribute on the Resource element.

Looking at class BasicDataSource this property is indeed there (field "connectionInitSqls")

However, the class BasicDataSourceFactory, the JNDI factory used by Tomcat to create a BasicDataSource instance, uses another attribute-name for this property:

private final static String PROP_INITCONNECTIONSQLS = "initConnectionSqls";
value = properties.getProperty(PROP_INITCONNECTIONSQLS);
if (value != null) {
  StringTokenizer tokenizer = new StringTokenizer(value, ";");

My suggestion is to keep the documentation as is and update the class BasicDataSourceFactory. For example like this (of course field name may also be updated too, to reflect the property name) :

private final static String PROP_INITCONNECTIONSQLS = "connectionInitSqls";
Comment 1 Mark Thomas 2015-09-07 12:50:51 UTC
This is https://issues.apache.org/jira/browse/DBCP-348

We need a Commons DBCP 1.4.1 release in order to fix this.
Comment 2 Mark Thomas 2019-03-15 23:24:01 UTC
Fixed in:
- 7.0.x for 7.0.94 onwards