2 Replies Latest reply on May 6, 2010 9:16 AM by kenbarnesjr

    Multiple datasources different IP's Dynamic selection of each

    kenbarnesjr

      I have one jboss server that runs on a box with 30+ instances of sybase one the same box with each instance of sybase having a different ip.  I have some web services that clients connect to wanting interaction with any one of the databases.  I can get the Ip address of each that are calling but I need a way to specify the datasource via JNDI that each should use.  Is there any way that I can have one datasource defined in Sybase-ds.xml and then in a module or some mechanism dynamically select the datasource according to IP and have the web service that utilzes the datasoure have the right one.  Would i need 30 ds.xml files each creating a jndi datasource ?

      Thanks for the help

        • 1. Re: Multiple datasources different IP's Dynamic selection of each
          peterj

          You will need 30 *-ds.xml files. There is no way, within the Java code that requests a data source, to specify an IP address for the connection. In addtion, such a capability would make connection pooling a real mess.

          • 2. Re: Multiple datasources different IP's Dynamic selection of each
            kenbarnesjr

            Thanks,

            I wont know the ip of the database they want to make a connection to until the web service call is made.  Currently I have a class that extends AbstractPasswordCredentialLoginModule that determines that sets the username and password if I know the IP address here can I dynamically set which datasource that the call will need?

            subject.getPrincipals().add(new SimplePrincipal(userName));
                    sharedState.put("javax.security.auth.login.name", userName);
                    PasswordCredential cred = new PasswordCredential(userName, password.toCharArray());
                    cred.setManagedConnectionFactory(getMcf());

            could I cred.setManagedConnectionFactory(XXX)

            where would i go do do something like this