Bug 53289 - Clarify ResourceLink example that uses getConnection(username, password)
Summary: Clarify ResourceLink example that uses getConnection(username, password)
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Documentation (show other bugs)
Version: 7.0.27
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-24 13:58 UTC by Konstantin Kolinko
Modified: 2012-05-25 06:43 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Kolinko 2012-05-24 13:58:15 UTC
It was reported on the users list:
http://marc.info/?t=133780532900005&r=1&w=2
http://markmail.org/thread/26yhdl7pfhdm2dic


In documentation there is example [1] on using a ResourceLink with specific value for the factory, org.apache.naming.factory.DataSourceLinkFactory. It allows to specify custom username and password while reusing connections from  a global datasource pool. This feature was added per bug 49543.


The problem is that there is an important bit that is lacking from the description: this feature requires support from the pool implementation for getConnection(username, password) method.

- In Apache Commons DBCP pool there is no support for that method [2]. An UnsupportedOperationException will be thrown. (DBCP 1.4)

- In Apache Tomcat JDBC pool support for this feature is off by default (username and password are ignored). It can be enabled by setting alternateUsernameAllowed="true". [3]


[1] http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Links

[2] http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html#getConnection%28java.lang.String,%20java.lang.String%29

[3] http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
Comment 1 Konstantin Kolinko 2012-05-25 06:43:53 UTC
Fixed in trunk r1342503
in 7.0.x r1342511 to be in 7.0.28,
in 6.0.x r1342515 to be in 6.0.36.