Bug 56779 - Allow multiple connection initialization statements
Summary: Allow multiple connection initialization statements
Status: NEW
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-07-28 17:22 UTC by Wes Clark
Modified: 2014-07-28 19:40 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Wes Clark 2014-07-28 17:22:40 UTC
Tomcat JDBC Enhanced Attribute initSQL is a string documented as " A custom query to be run when a connection is first created."  Often multiple statements (not really "queries") need to be executed to initialize a connection, and you only want to do this once.  There are rather involved workarounds to pass a single "statement" which executes multiple statements, but the interface would be improved if more than one statement could be specified. See DBCP2 BasicDataSource.setConnectionInitSqls(Collection<String> connectionInitSqls).
Comment 1 Christopher Schultz 2014-07-28 19:22:38 UTC
The problem with putting multiple statements into the "initSQL" attribute value is that tomcat-pool then needs to basically implement a SQL statement parser in order to determine where each statement starts and ends.

If a special character could be used between statements that is extremely unlikely to be used in one of the SQL statements (for instance, vertical tab) such statements could be separated by that instead of something more natural such as a semicolon.
Comment 2 Filip Hanik 2014-07-28 19:40:15 UTC
well, I like the idea of copying the API
BasicDataSource.setConnectionInitSqls(Collection<String> connectionInitSqls)

after all, the copied the idea of init SQL from us :)
that way programmatically it works, and more sophisticated DI frameworks have no problems injecting collections.

In Tomcat server.xml, we can still use a single string, like the work around

that folks have been using today