how can I use two different databases in one web application?

From: Garcia Corral, Josep (josep.garci..ecsidel.es)
Date: Fri May 09 2008 - 08:17:37 EDT

  • Next message: Michael Gentry: "Re: how can I use two different databases in one web application?"

    Hello,

    I am using the last stable version of Cayenne: 2.0.4.

     

    The situation is:

    Database 1: oracle, with tables A, B

    Database 2: mysql, with tables C, D, E

     

    First question is: what's the best way to define this in a Cayenne
    Project?

     

    First_Domain:

                First_DomainMap

                First_DomainNode

    Second_Domain:

                Second_DomainMap

                Second_DomainNode

     

    or:

     

    Domain:

                First_DomainMap

                First_DomainNode

                Second_DomainMap

                Second_DomainNode

     

    And then, from a servlet, how can I have access to tables from Database
    1 and 2? What I have used so far is:

     

     

    I tried this but it did not work:

                DataContext.createDataContext("First_Domain");

    ...

     

    This did not work either:

    HttpSession session = req.getSession();

    DataContext context = ServletUtil.getSessionContext(session);

    Expression qualifier = Expression.fromString(some_condition);

    SelectQuery select = new SelectQuery(A.class, qualifier);

    ...

    qualifier = Expression.fromString(other_condition);

    select = new SelectQuery(C.class, qualifier);

     

     

    Josep Garcia

     



    This archive was generated by hypermail 2.0.0 : Fri May 09 2008 - 08:18:15 EDT