4 Replies Latest reply on Oct 6, 2010 4:18 AM by wdfink

    User-specific connections

    nickarls

      Hi,

       

        Is it possible to configure datasources so that the database connections would be user-specific? Of course it would be a performance/cache bottleneck if the connections would actually be made as the user, I'm looking for some way of "switching" users on a live connection.

        • 1. Re: User-specific connections
          wdfink

          AFAIK not.

          The user is specific to the *-ds.xml.

           

          Only way is to use multiple *-ds.xml configuration, but indeed it is not dynamic and might a connection overload of the database.

          • 2. Re: User-specific connections
            nickarls

            I have a theory that it could be done with a custom JCA LoginModule but I haven't looked into it more closely (and it's for the JCA forum)

            • 3. Re: User-specific connections
              northgorky

              I did this a while back with JBoss 4.2.2.  I would dynamically create a DS, then load it in the jNDI tree, with part of the path based on the company name of the user.  Code would then retrieve connection from JNDI based on the user's company name.  Neat thing was, I set the min connection value in the connection pool to 0, so if nobody was actually using that connection, the connections would close.  The specifics won't work for JBoss 5, but you might be able to adapt them.  I posted this on the mailing list ages ago, and the forum some time ago.  If you need and can't find, let me know.  If you wind up using this solution and patching for JBoss 5., I would appreciate an email to where you posted the upgrade.

               

              Regards,

              Steve

              • 4. Re: User-specific connections
                wdfink

                I found something in the configuration.

                You can use <application-mananged-security/> within the *-ds.xml (see generic-ds.xml) docs/examples/jca.

                You are able to use getConnectio(use,psw) within the application. I'm not sure whether this is practicable with JPA ;-)

                Also I'm not sure what the behaviour of pool is.