Dynamic database attribute

From: John Armstrong (siberia..mail.com)
Date: Mon Jun 16 2008 - 00:55:54 EDT

  • Next message: Andrus Adamchik: "Re: Dynamic database attribute"

    Hello Cayenne people,
      First off, thank god for Cayenne. Its made my life a lot better and
    Hibernate is but a nightmare now. Thanks.

    Ok so my issue. I have a stand-alone app. In this app it uses the ant
    api to create a derby database in the users home directory. Some
    snippets:

    I config ant as :
                    p.setProperty("dbFile", System.getProperty("user.home")
                                    + "/portfolioDB");

    And then my build.xml says:
    <database url="jdbc:derby:${dbFile}"
    driverClassName="org.apache.derby.jdbc.EmbeddedDriver" username=""
    password="" />

    This allows me to inject my ddl into the database on first run and
    have the database be localized to the user account across platforms.

    I need a way to inject this same ${dbFile} context into the
    *Node.driver file so that Cayenne accesses the database I just created
    and populated at first run.

    Currently mine says:

    <url value="jdbc:derby:/portfolioDB;create=true"/>

    Which obviously is not dynamic. It would be great if I could set it to
    <url value="jdbc:derby:${dbFile};create=true"/>

    Is this possible? I am imagining a way to set an environment variable
    or some sort of custom config class that sets this. This app is
    launched from a webstart so rewriting the config file is not a good
    answer for me unless I absolutely have to. That would obviously
    require a custom config class of some sort but is a level of
    complexity that feels unnecessary.

    Thanks, this is a bit into the internals for me and I lose my way quickly.

    John-



    This archive was generated by hypermail 2.0.0 : Mon Jun 16 2008 - 00:56:28 EDT