Bug 58338

Summary: BasicDataSourceFactory uses wrong attribute name
Product: Tomcat 7 Reporter: Stephan van Hoof <hoof>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 7.0.64   
Target Milestone: ---   
Hardware: PC   
OS: All   

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, ";");
  dataSource.setConnectionInitSqls(Collections.list(tokenizer));
}
...

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