2 Replies Latest reply on Mar 14, 2003 3:58 AM by Andrew May

    Dynamically changing ConnectionURL

    Andrew May Newbie


      I'm using a series of BASIS databases (it's a specialist bibliographic database) with a connection URL of the form:


      where each uncnn.all is a seperate database. Occasionally the databases go off-line or are swapped out for other databases, and I need to be able to dynamically change the url and restart the connection url. I also need to be able to shut down the connection pool for periods of time.

      The list of currently active databases is found in a configuration file which gets checked every minute.

      We're using 3.0.3. I've been looking at the code for the RARDeployment mbean, and I was considering sub-classing this, but I'm not sure whether it would be able to redeploy the ManagedConnectionFactory by itself.

      At the moment the only way I can see how to do it is to have an MBean that depends on the ConnectionManager, and when it wants to change the URL calls setManagedConnectionFactoryAttribute on the RARDeployer that the ConnectionManager depends upon, then calls stop() and start() on the ConnectionManger. However that seems like a brute force approach.

      Any ideas?



        • 1. Re: Dynamically changing ConnectionURL
          David Jencks Master

          I don't understand your requirements yet. At any one time are all connections to a single database?

          There is better support for this in 3.0.7 (currently cvs only I believe). There's an operation something like setManagedConnectionFactoryProperty you can use to reset the ConnectionURL and the pool has a flush method to get rid of all the old and presumably useless connections to the old db. I think the same capabilities are in 3.2 and 4: in 4 the mcf is exposed directly as an (x)mbean so you can set the property directly.

          I dont think you need to call stop and start... this will probably mess up any DataSources you might have been caching.

          • 2. Re: Dynamically changing ConnectionURL
            Andrew May Newbie

            Thanks, it sound like being able to change the connection URL and then flush the pool in 3.0.7 or 3.2 will do the trick - I'm not brave enough to go with 4 as we've got to go into production with this fairly soon.

            We don't cache the DataSource - in our current live implementation (under WebLogic 5.1 which we're migrating from) we remove the DataSource as an indication that the datasource is not available.

            Here's a bit of background on our setup if you're interested:
            With BASIS there's a database kernel on which there might be a number of different individual databases (which are a bit like schemas in Oracle) - in the connection url you have to specify which databases on the kernel that you're going to query.

            In this case the different databases are individual years of bibliographic content, and we typically do a search over a range of year therefore accessing a number of databases, but with the same connection (specifying the database in the qry).

            Because BASIS doesn't like to be queried at the same time as it's updated we have a shutdown for an hour or so every week when the loading is performed.

            During the week if there's any problems or other changes need to be made, individual databases are made unavailable or replaced with copies, and this is when we need to be able to dynamically change the connection url.