Sorry, for the wall of text. :)

"IIRC there is no support for getConnection(username, password) in
Apache Commons DBCP pool at all, and it was a new feature in Tomcat
JDBC pool at that time."

Yes,  it is the problem. I've lost many hours following an example in
documentation about ResourceLink and DataSource that does not work as
expected/described.


Best regards,

Robert

On Wed, May 23, 2012 at 8:26 PM, Konstantin Kolinko
<knst.koli...@gmail.com>wrote:

> 2012/5/24 Robert Anderson <ranom...@gmail.com>:
> >
> > 2. You need to set alternateUsernameAllowed="
> >>
> >> true" on Tomcat JDBC pool  [1]
> >> Otherwise arguments in ds.getConnection(user,password) method on that
> >> datasource are ignored.
> >
> >
> > Good, I'll test it. Anyway, the following description and example in
> > documentation is not valid (
> > tomcat.apache.org/tomcat-6.0-doc/config/context.html#Resource_Links,
> > tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Links):
> >
> > "When the attribute
> > factory="org.apache.naming.factory.DataSourceLinkFactory" the resource
> link
> > can be used with two additional attributes to allow a shared data source
> to
> > be used with different credentials. When these two additional attributes
> > are used in combination with the javax.sql.DataSource type, different
> > contexts can share a global data source with different credentials. Under
> > the hood, what happens is that a call to
> > getConnection()<
> http://download.oracle.com/javase/6/docs/api/javax/sql/DataSource.html#getConnection%28%29
> >is
> > simply translated to a call getConnection(username,
> > password)<
> http://download.oracle.com/javase/6/docs/api/javax/sql/DataSource.html#getConnection%28java.lang.String,%20java.lang.String%29
> >on
> > the global data source. This is an easy way to get code to be
> > transparent to what schemas are being used, yet be able to control
> > connections (or pools) in the global configuration. "
> >
> > <GlobalNamingResources>
> >  ...
> >  <Resource name="sharedDataSource"
> >            global="sharedDataSource"
> >            type="javax.sql.DataSource"
> >            username="bar"
> >            password="barpass"
> >
> >            ...
> >  ...
> > </GlobalNamingResources>
> >
> > <Context path="/foo"...>
> >  ...
> >  <ResourceLink
> >            name="appDataSource"
> >            global="sharedDataSource"
> >            type="javax.sql.DataSource"
> >            factory="org.apache.naming.factory.DataSourceLinkFactory"
> >            username="foo"
> >            password="foopass"
> >  ...
> > </Context>
> > <Context path="/bar"...>
> >  ...
> >  <ResourceLink
> >            name="appDataSource"
> >            global="sharedDataSource"
> >            type="javax.sql.DataSource"
> >  ...
> > </Context>
> >
> >
> >
> > That way, just does not work.
> >
>
> Can you be more specific? You are just citing a wall of text and it is
> hard to digest.
>
> Can you open an issue in Bugzilla?
>
> IIRC there is no support for getConnection(username, password) in
> Apache Commons DBCP pool at all, and it was a new feature in Tomcat
> JDBC pool at that time.
>
> Is it the problem, or something else is wrong?
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to