Class ErrorLogReader

java.lang.Object
org.apache.derby.vti.VTITemplate
org.apache.derby.diag.ErrorLogReader
All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper, AwareVTI

public class ErrorLogReader extends VTITemplate
ErrorLogReader is a virtual table interface (VTI) which contains all the statements of "interest" in db2j.log or a specified file when db2j.language.logStatementText=true.

One use of this VTI is to determine the active transactions and the SQL statements in those transactions at a given point in time, say when a deadlock or lock timeout occurred. In order to do that, you must first find the timestamp (timestampConstant) of interest in the error log. The SQL to view the active transactions at a given in time is:

SELECT vti.ts, threadid, cast(xid as int) as xid_int, cast(lccid as int) as lccid_int, logtext 
                 FROM new org.apache.derby.diag.ErrorLogReader() vti, 
                        (VALUES timestampConstant) t(ts)
                 WHERE vti.ts <= t.ts AND 
                                vti.ts >
                                        (SELECT MAX(ts) IS NULL ? '2000-01-01 00:00:00.1' : MAX(ts)
                                         FROM new org.apache.derby.diag.ErrorLogReader() vti_i
                                         WHERE (logtext LIKE 'Committing%' OR
                                                        logtext LIKE 'Rolling%') AND
                                                   vti.xid = vti_i.xid AND ts < t.ts)
                 ORDER BY xid_int, vti.ts
        

The ErrorLogReader virtual table has the following columns:

  • TS varchar(26) - the timestamp of the statement.
  • THREADID varchar(40) - the thread name.
  • XID varchar(15) - the transaction ID.
  • LCCID varchar(15) - the connection ID.
  • DATABASE varchar(128) - Database name
  • DRDAID varchar(50) - nullable. DRDA ID for network server session.
  • LOGTEXT long varchar - text of the statement or commit or rollback.