Guy Rouillier wrote:

> I think J2EE (and JBoss) handle this, though I may have found a bug in

You are quite right that the spec allows this. Apologies for the
misinformation.

The relevent section of the EJB2.0 spec that I have is 19.4.

> JBoss.  In jboss.jcml, when you create your connection pool, provide a URL
> but do not provide a userid or password.  The MBean will start up
> successfully.  In your bean code, use this form of connect statement:
> 
>    Connection connection = ((DataSource)new
> InitialContext().lookup("java:comp/env/jdbc/OracleDB")).getConnection("myuse
> rid", "mypassword");
> 
> Now your connection will use the credentials of the userid provided.  I've
> tried this and it seems to work

Now, JBoss's support of this is obtained from Minerva. Looking at the
code for XAPoolDataSource, we see:

    /**
     * Gets a new connection from the pool.  If a new connection must be
     * created, it will use the specified user name and password.  If there is
     * a connection available in the pool, it will be used, regardless of the
     * user name and password use to created it initially.
     */
    public Connection getConnection(String user, String password) throws 
java.sql.SQLException {
        if(!initialized) initialize();
        factory.setUser(user);
        factory.setPassword(password);
        return ((XAConnection)pool.getObject()).getConnection();
    }

So, Minerva does not do what you might expect, unless you are never
returning your connections to the pool.

This is superceded by the JCA stuff, which knows how to handle the case
of requesting connections on behalf of different principals.

Toby.


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to