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:
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private BufferedReader | |
| private static final ResultColumnDescriptor[] | |
| private int | |
| private int | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private static final String | |
| private int | |
| private boolean | |
| private String | |
| private InputStreamReader | |
| private InputStream | |
| private int | |
| private String | |
| private static final ResultSetMetaData | |
| private static final String | |
| private int | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | ErrorLogReader()
ErrorLogReader() accesses the derby.log in derby.system.home, if set, otherwise it looks in the current directory. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Releases this |
| public ResultSetMetaData | getMetaData()
Overrides org. Implements java. Retrieves the number, types and properties of
this |
| public String | getString(int
the first column is 1, the second is 2, ... columnNumber)Overrides org. Implements java. All columns in the Db2jLogReader VTI have a of String type. |
| public boolean | next()
Implements java. Moves the cursor forward one row from its current position. |
| public boolean | wasNull()
Overrides org. Implements java. Reports whether
the last column read had a value of SQL |
| BEGIN_DATABASE_STRING | back to summary |
|---|---|
| private static final String BEGIN_DATABASE_STRING | |
| BEGIN_DRDAID_STRING | back to summary |
|---|---|
| private static final String BEGIN_DRDAID_STRING | |
| BEGIN_EXECUTING_STRING | back to summary |
|---|---|
| private static final String BEGIN_EXECUTING_STRING | |
| BEGIN_THREAD_STRING | back to summary |
|---|---|
| private static final String BEGIN_THREAD_STRING | |
| BEGIN_XID_STRING | back to summary |
|---|---|
| private static final String BEGIN_XID_STRING | |
| bufferedReader | back to summary |
|---|---|
| private BufferedReader bufferedReader | |
| columnInfo | back to summary |
|---|---|
| private static final ResultColumnDescriptor[] columnInfo | |
| databaseIndex | back to summary |
|---|---|
| private int databaseIndex | |
| drdaidIndex | back to summary |
|---|---|
| private int drdaidIndex | |
| END_DATABASE_STRING | back to summary |
|---|---|
| private static final String END_DATABASE_STRING | |
| END_DRDAID_STRING | back to summary |
|---|---|
| private static final String END_DRDAID_STRING | |
| END_EXECUTING_STRING | back to summary |
|---|---|
| private static final String END_EXECUTING_STRING | |
| END_THREAD_STRING | back to summary |
|---|---|
| private static final String END_THREAD_STRING | |
| END_TIMESTAMP | back to summary |
|---|---|
| private static final String END_TIMESTAMP | |
| END_XID_STRING | back to summary |
|---|---|
| private static final String END_XID_STRING | |
| endTimestampIndex | back to summary |
|---|---|
| private int endTimestampIndex | |
| gotFile | back to summary |
|---|---|
| private boolean gotFile | |
| inputFileName | back to summary |
|---|---|
| private String inputFileName | |
| inputFileStreamReader | back to summary |
|---|---|
| private InputStreamReader inputFileStreamReader | |
| inputStream | back to summary |
|---|---|
| private InputStream inputStream | |
| lccidIndex | back to summary |
|---|---|
| private int lccidIndex | |
| line | back to summary |
|---|---|
| private String line | |
| metadata | back to summary |
|---|---|
| private static final ResultSetMetaData metadata | |
| PARAMETERS_STRING | back to summary |
|---|---|
| private static final String PARAMETERS_STRING | |
| threadIndex | back to summary |
|---|---|
| private int threadIndex | |
| xidIndex | back to summary |
|---|---|
| private int xidIndex | |
| ErrorLogReader | back to summary |
|---|---|
| public ErrorLogReader() throws StandardException ErrorLogReader() accesses the derby.log in derby.system.home, if set, otherwise it looks in the current directory. ErrorLogReader('filename') will access the specified file name. | |
| ErrorLogReader | back to summary |
|---|---|
| public ErrorLogReader(String inputFileName) throws StandardException | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Releases this The closing of a
When a Note A
Calling the method
| |
| getMetaData | back to summary |
|---|---|
| public ResultSetMetaData getMetaData() Overrides org. Implements java. Doc from java. Retrieves the number, types and properties of
this
| |
| getString | back to summary |
|---|---|
| public String getString(int columnNumber) throws SQLException Overrides org. Implements java. All columns in the Db2jLogReader VTI have a of String type.
| |
| next | back to summary |
|---|---|
| public boolean next() throws SQLException Implements java. Doc from java. Moves the cursor forward one row from its current position.
A
When a call to the If an input stream is open for the current row, a call
to the method
| |
| wasNull | back to summary |
|---|---|
| public boolean wasNull() Overrides org. Implements java. Doc from java. Reports whether
the last column read had a value of SQL
| |