users@glassfish.java.net

javadb derby - getting statistics for java query language

From: <glassfish_at_javadesktop.org>
Date: Mon, 21 Sep 2009 02:28:27 PDT

Hi!

I'm trying to check statistics for a query written in the java query language and executed in a stateless java bean. I've tried the following code but it doesn't work:

//bean method
public void statistics() throws SQLException {
        System.out.println("startStatistics()");
        Connection c = dataSource.getConnection();
        CallableStatement cs = c.prepareCall("CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()");
        System.out.println(cs.execute());
        cs.close();
        cs = c.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(1)");
        System.out.println(cs.execute());
        cs.close();
        Query q = em.createNamedQuery("TestTable.findAll");
        q.getResultList();
        cs = c.prepareCall("VALUES SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS()");
        ResultSet rs = cs.getResultSet();
        if (rs != null) {
            while (rs.next()) {
                String res = rs.getString(1);
                System.out.println(res);
            }
        }
        cs.close();
        cs = c.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_RUNTIMESTATISTICS(0)");
        System.out.println(cs.execute());
        cs.close();
        c.close();
        System.out.println("/startStatistics()");
    }

execution returns:

startStatistics()
false
false
false
/startStatistics()

Has anybody tried any other way to do this?
[Message sent by forum member 'dziku' (kpach_at_poczta.onet.pl)]

http://forums.java.net/jive/thread.jspa?messageID=364894