Re: How to retrive a connection

From: Bryan Lewis (brya..aine.rr.com)
Date: Fri Mar 17 2006 - 07:59:21 EST

  • Next message: Bill Dudney: "mailing lists done..."

    Here's what I use.

        /**
         * Get a Connection from Cayenne's pool. Sometimes we want to execute
         * queries through plain old JDBC.
         */
        public Connection getConnection()
        {
            try {
                DataContext dc = getDataContext();
                DataDomain domain = dc.getParentDataDomain();
                // I have only one dataNode...
                DataNode dataNode = (DataNode)
    domain.getDataNodes().iterator().next();
                DataSource dataSource = dataNode.getDataSource();
                return dataSource.getConnection();
            }
            catch (Exception ex) {
                // Do something.
            }
        }

    Enrico Donelli wrote:

    > Is there any way to have a Connection object?
    > I'm using HSQLDB, and I would like to be able to run the command
    > "CHECKPOINT DEFRAG" from the application, but I did not find a way to
    > get the connection...
    >
    > Thanks in advance
    >
    > Enrico
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Mar 17 2006 - 07:59:28 EST