org.apache.derby.diag
Class ErrorLogReader
java.lang.Object
org.apache.derby.vti.VTITemplateBase
org.apache.derby.vti.VTITemplate
org.apache.derby.diag.ErrorLogReader
- All Implemented Interfaces:
- java.sql.ResultSet, java.sql.Wrapper
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.
| Fields inherited from interface java.sql.ResultSet |
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE |
|
Constructor Summary |
ErrorLogReader()
ErrorLogReader() accesses the derby.log in
derby.system.home, if set, otherwise it looks in the current directory. |
ErrorLogReader(java.lang.String inputFileName)
|
|
Method Summary |
void |
close()
|
java.sql.ResultSetMetaData |
getMetaData()
|
java.lang.String |
getString(int columnNumber)
All columns in the Db2jLogReader VTI have a of String type. |
boolean |
next()
|
boolean |
wasNull()
|
| Methods inherited from class org.apache.derby.vti.VTITemplate |
getBigDecimal, getBigDecimal, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getObject, getShort, getString, getTime, getTimestamp |
| Methods inherited from class org.apache.derby.vti.VTITemplateBase |
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getByte, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDouble, getFetchDirection, getFetchSize, getFloat, getInt, getLong, getObject, getObject, getObject, getRef, getRef, getRow, getShort, getStatement, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, notImplemented, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateShort, updateShort, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.sql.ResultSet |
getHoldability, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getRowId, getRowId, getSQLXML, getSQLXML, isClosed, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateRowId, updateRowId, updateSQLXML, updateSQLXML |
| Methods inherited from interface java.sql.Wrapper |
isWrapperFor, unwrap |
gotFile
private boolean gotFile
inputFileStreamReader
private java.io.InputStreamReader inputFileStreamReader
inputStream
private java.io.InputStream inputStream
bufferedReader
private java.io.BufferedReader bufferedReader
inputFileName
private java.lang.String inputFileName
line
private java.lang.String line
endTimestampIndex
private int endTimestampIndex
threadIndex
private int threadIndex
xidIndex
private int xidIndex
lccidIndex
private int lccidIndex
databaseIndex
private int databaseIndex
drdaidIndex
private int drdaidIndex
END_TIMESTAMP
private static final java.lang.String END_TIMESTAMP
- See Also:
- Constant Field Values
PARAMETERS_STRING
private static final java.lang.String PARAMETERS_STRING
- See Also:
- Constant Field Values
BEGIN_THREAD_STRING
private static final java.lang.String BEGIN_THREAD_STRING
- See Also:
- Constant Field Values
END_THREAD_STRING
private static final java.lang.String END_THREAD_STRING
- See Also:
- Constant Field Values
BEGIN_XID_STRING
private static final java.lang.String BEGIN_XID_STRING
- See Also:
- Constant Field Values
END_XID_STRING
private static final java.lang.String END_XID_STRING
- See Also:
- Constant Field Values
BEGIN_DATABASE_STRING
private static final java.lang.String BEGIN_DATABASE_STRING
- See Also:
- Constant Field Values
END_DATABASE_STRING
private static final java.lang.String END_DATABASE_STRING
- See Also:
- Constant Field Values
BEGIN_DRDAID_STRING
private static final java.lang.String BEGIN_DRDAID_STRING
- See Also:
- Constant Field Values
END_DRDAID_STRING
private static final java.lang.String END_DRDAID_STRING
- See Also:
- Constant Field Values
BEGIN_EXECUTING_STRING
private static final java.lang.String BEGIN_EXECUTING_STRING
- See Also:
- Constant Field Values
END_EXECUTING_STRING
private static final java.lang.String END_EXECUTING_STRING
- See Also:
- Constant Field Values
columnInfo
private static final ResultColumnDescriptor[] columnInfo
metadata
private static final java.sql.ResultSetMetaData metadata
ErrorLogReader
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.
- Throws:
StandardException
ErrorLogReader
public ErrorLogReader(java.lang.String inputFileName)
throws StandardException
- Throws:
StandardException
getMetaData
public java.sql.ResultSetMetaData getMetaData()
- Specified by:
getMetaData in interface java.sql.ResultSet- Overrides:
getMetaData in class VTITemplateBase
- See Also:
ResultSet.getMetaData()
next
public boolean next()
throws java.sql.SQLException
- Specified by:
next in interface java.sql.ResultSet- Specified by:
next in class VTITemplate
- Throws:
java.sql.SQLException - If database-access error occurs.- See Also:
ResultSet.next()
close
public void close()
- Specified by:
close in interface java.sql.ResultSet- Specified by:
close in class VTITemplate
- See Also:
ResultSet.close()
getString
public java.lang.String getString(int columnNumber)
throws java.sql.SQLException
- All columns in the Db2jLogReader VTI have a of String type.
- Specified by:
getString in interface java.sql.ResultSet- Overrides:
getString in class VTITemplateBase
- Throws:
java.sql.SQLException - If database-access error occurs.- See Also:
ResultSet.getString(int)
wasNull
public boolean wasNull()
- Specified by:
wasNull in interface java.sql.ResultSet- Overrides:
wasNull in class VTITemplateBase
- See Also:
ResultSet.wasNull()
Apache Derby V10.10 Internals - Copyright © 2004,2013 The Apache Software Foundation. All Rights Reserved.