RE: How i can read at runtime datasource info?

From: Pirola Davide (davide.pirol..tin.it)
Date: Thu Apr 14 2005 - 09:30:55 EDT

  • Next message: Andrus Adamchik: "RE: How i can read at runtime datasource info?"

    Hi Andrus,
    i use both the configuration...(DriverDataSourceFactory / container-provided DataSource JNDI)
    one for production and one for develop.
    There is a unique way to retrive this infomation?
    I need at least the JDBC URL.
    Thank's
    Davide

    -----Original Message-----
    From: Andrus Adamchik [mailto:andru..bjectstyle.org]
    Sent: giovedì 14 aprile 2005 15.03
    To: cayenne-use..bjectstyle.org
    Subject: Re: How i can read at runtime datasource info?

    > Hi,
    > i want to read dasource info at runtime. I see that "DatasourceInfo"
    > class have all the property that i need. How i can obtain an instance of
    > this class?
    > From a "Configuration" oject?
    > From a "DataDomain" object?
    >
    > Thank's
    > Davide

    Hi Davide,

    You are on the right track, but go even lower down the stack. You need to
    obtain DataNod, then call getDataSource, casting the result to
    org.objectstyle.cayenne.conn.PoolManager. Pool manager has al the info you
    need.

    Of course the cast to PoolManager is valid only if you configured
    DriverDataSourceFactory for the DataNode in the Modeler. If it is a
    container-provided DataSource (i.e. obtained via JNDI), this won't work.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Apr 14 2005 - 09:29:08 EDT