Announcement Announcement Module
No announcement yet.
Can't set thread-bound database credentials in tcServer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't set thread-bound database credentials in tcServer

    In Websphere I was able to wire an interceptor around all of my controllers and set thread-bound DB credentials based on the path of the current request. In my tcServer Developer edition (2.3.3 M1) this no longer works. My datasource is wired as a

    org.springframework.jdbc.datasource.UserCredential sDataSourceAdapter

    I've verified that I'm calling the getConnection(String username, String password) method with the correct credentials. However, the connection that is returned is of type

    ProxyConnection[PooledConnection[[email protected]]]

    with the same default credentials as those defined in server.xml. Is there another way to set the database credentials at runtime?

  • #2
    This is an issue with the new jdbc-pool implementation, it internally always uses the default configured username/password. I suggest raising a bug on the tomcat(jdbc-pool) issue tracker.

    The actual code.
    public class DataSourceProxy implements PoolConfiguration {
         * {@link javax.sql.DataSource#getConnection()}
        public Connection getConnection(String username, String password) throws SQLException {
            return getConnection();
    Last edited by Marten Deinum; Sep 29th, 2010, 02:06 AM.