Changing database schemas at runtime

From: Lawrence Gerstley (lawger..mail.com)
Date: Mon Jan 05 2009 - 20:57:25 EST

  • Next message: Andrus Adamchik: "Re: Changing database schemas at runtime"

    Hello,

    I've been using Cayenne and allowing for changing backends at runtime--
    representing the same schema in MySQL, Oracle, Apache Derby, and have
    had success changing the backend with:

                 DataSource dataSource = new PoolManager(
                         jdbcDriverDetails.getDriverClass(),
                         myURL,
                         1,
                         5,
                         myUser,
                         myPassword);
                 Configuration config =
    Configuration.getSharedConfiguration();
                 DataDomain domain = config.getDomain();
                 DataNode node = domain.getNode("MyDomain");
                 node.setDataSource(dataSource);

    My problem is that I need to also allow a user to select the schema
    that the datamap should be applied to. For example, in Oracle, the
    same schema design might be in multiple instances (in my example,
    KTMI3D, KTMI3M, KTMI3X, etc.). I can change these with the modeler and
    have it work, but I need to change it at runtime. I've tried changing
    it with:

                 dataMap.setDefaultSchema(schema);

    But haven't had much luck changing at runtime. Is there some way to do
    this with my approach, or is there a better approach to take if you
    want to switch back-ends multiple time at runtime?

    Thanks for reading,

    Lawrence



    This archive was generated by hypermail 2.0.0 : Mon Jan 05 2009 - 20:58:06 EST