Well, by reading the source for DBCP 1.2.1, I can see that
BasicDataSource method:

    getConnection(String username, String password)

is not supported because the delegate which BasicDataSource
uses, an instance of PoolingDataSource, throws an
UnsupportedOperationException in method:

    getConnection(String username, String password).




This essentially tells me that Tomcat 5.5.17 does not
support an Application-managed DataSource if you use the
standard  Java API.  You can, however, cast the
DataSource returned from JNDI to:

    org.apache.tomcat.dbcp.dbcp.BasicDataSource

and then call the following before getting the first
connection (where "ds" is the reference to the
BasicDataSource):

    ds.setUsername(username);
    ds.setPassword(password);

or:

    ds.addConnectionProperty("user", username);
    ds.addConnectionProperty("password", password);

This, of course, makes the code Tomcat-specific.




Mark Barnes wrote:
I just cannot seem to get an Application-managed DataSource to work!


I am using Tomcat 5.5.17 on JDK 1.5.0_07 on Red Hat Linux.

I have done what I think is required in the context.xml and the web.xml files for my application to enable an Application-managed DataSource, and have done what is require to get the DataSource and get a connection from it, passing the correct username & password, but when I try to get my first connection to the database I always get an Exception telling me the username/password are invalid.

I have included below copies of the Stack Trace Back, the context.xml, the web.xml, and the code used to access the DataSource and get the connection.

Everything was working fine with the same username & password using a Container-managed DataSource, but now I have the requirement that I get the plain-text username & password out of the XML files.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to