For some reason I thought Cayenne made a JNDI request whenever it needed a connection? Typically the JNDI data source (such as in Tomcat/JBoss/etc) is managing the connection pool, so this seems to me the logical thing.
For Cayenne-managed pools, I know it caches the connection information. I was thinking of changing that behavior a while back because if you store your DB password outside the model it won't re-read the password when attempting to reconnect. mrg On Mon, Mar 21, 2011 at 8:31 AM, Andrus Adamchik <[email protected]> wrote: > Yeah, Cayenne DataNode obtains DataSource once and stores it for future use. > Not sure if a better long-term strategy would be to do JNDI lookups every > time ? (maybe not), but for now you may either (1) write your own factory > that creates a simple DataSource wrapper that grabs a fresh DS via JNDI every > time a connection is requested, or (2) call DataNode.setDataSource(..) during > your environment reset process. > > Andrus > > > On Mar 21, 2011, at 2:12 PM, Hans Pikkemaat wrote: >> Hi, >> >> I have a unit test where I use jndi to determine my connection parameters. >> >> When I run one unit test which uses a specific jndi setup and it calls >> cayenne then >> all works fine (i use org.apache.cayenne.conf.JNDIDataSourceFactory) >> >> I then clear my jndi container and repopulate it with different connection >> details >> (different database). >> >> Running cayenne again still uses the earlier connection. Recreating a data >> context >> doesn't seem to help. I also tried >> Configuration.getSharedConfiguration().shutdown() >> but this also doesn't help. >> >> Maybe the connections are re-used? If so, is there a way to clear those? >> >> In general, is there a way to reset cayenne in such a way that my above unit >> testing will work? >> >> tx >> >> Hans >> >> > >
