Top Description Fields Constructors Methods
org.apache.derby.diag

public Class ErrorLogReader

extends VTITemplate
Class Inheritance
Imports
java.io.BufferedReader, .FileNotFoundException, .InputStream, .InputStreamReader, .FileInputStream, java.sql.ResultSetMetaData, .SQLException, .Types, org.apache.derby.vti.VTITemplate, org.apache.derby.shared.common.reference.Limits, .Property, org.apache.derby.iapi.util.StringUtil, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.sql.ResultColumnDescriptor, org.apache.derby.impl.jdbc.EmbedResultSetMetaData

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:

Field Summary

Modifier and TypeField 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

Constructor Summary

AccessConstructor and Description
public
ErrorLogReader()

ErrorLogReader() accesses the derby.log in derby.system.home, if set, otherwise it looks in the current directory.

public
ErrorLogReader(String inputFileName)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.sql.ResultSet.close.

Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

public ResultSetMetaData
getMetaData()

Overrides org.apache.derby.vti.VTITemplate.getMetaData.

Implements java.sql.ResultSet.getMetaData.

Retrieves the number, types and properties of this ResultSet object's columns.

public String
getString(int
the first column is 1, the second is 2, ...
columnNumber
)

Overrides org.apache.derby.vti.VTITemplate.getString.

Implements java.sql.ResultSet.getString.

All columns in the Db2jLogReader VTI have a of String type.

public boolean
next()

Implements java.sql.ResultSet.next.

Moves the cursor forward one row from its current position.

public boolean
wasNull()

Overrides org.apache.derby.vti.VTITemplate.wasNull.

Implements java.sql.ResultSet.wasNull.

Reports whether the last column read had a value of SQL NULL.

Inherited from org.apache.derby.vti.VTITemplate:
absoluteafterLastbeforeFirstcancelRowUpdatesclearWarningsdeleteRowfindColumnfirstgetArraygetArraygetAsciiStreamgetAsciiStreamgetBigDecimalgetBigDecimalgetBigDecimalgetBigDecimalgetBinaryStreamgetBinaryStreamgetBlobgetBlobgetBooleangetBooleangetBytegetBytegetBytesgetBytesgetCharacterStreamgetCharacterStreamgetClobgetClobgetConcurrencygetContextgetCursorNamegetDategetDategetDategetDategetDoublegetDoublegetFetchDirectiongetFetchSizegetFloatgetFloatgetHoldabilitygetIntgetIntgetLonggetLonggetNCharacterStreamgetNCharacterStreamgetNClobgetNClobgetNStringgetNStringgetObjectgetObjectgetObjectgetObjectgetObjectgetObjectgetRefgetRefgetReturnTableSignaturegetRowgetRowIdgetRowIdgetShortgetShortgetSQLXMLgetSQLXMLgetStatementgetStringgetTimegetTimegetTimegetTimegetTimestampgetTimestampgetTimestampgetTimestampgetTypegetUnicodeStreamgetUnicodeStreamgetURLgetURLgetWarningsinsertRowisAfterLastisBeforeFirstisClosedisFirstisLastisWrapperForlastmoveToCurrentRowmoveToInsertRownotImplementedpreviousrefreshRowrelativerowDeletedrowInsertedrowUpdatedsetContextsetFetchDirectionsetFetchSizeunwrapupdateArrayupdateArrayupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateAsciiStreamupdateBigDecimalupdateBigDecimalupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBinaryStreamupdateBlobupdateBlobupdateBlobupdateBlobupdateBlobupdateBlobupdateBooleanupdateBooleanupdateByteupdateByteupdateBytesupdateBytesupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateCharacterStreamupdateClobupdateClobupdateClobupdateClobupdateClobupdateClobupdateDateupdateDateupdateDoubleupdateDoubleupdateFloatupdateFloatupdateIntupdateIntupdateLongupdateLongupdateNCharacterStreamupdateNCharacterStreamupdateNCharacterStreamupdateNCharacterStreamupdateNClobupdateNClobupdateNClobupdateNClobupdateNClobupdateNClobupdateNStringupdateNStringupdateNullupdateNullupdateObjectupdateObjectupdateObjectupdateObjectupdateRefupdateRefupdateRowupdateRowIdupdateRowIdupdateShortupdateShortupdateSQLXMLupdateSQLXMLupdateStringupdateStringupdateTimeupdateTimeupdateTimestampupdateTimestamp

Field Detail

BEGIN_DATABASE_STRINGback to summary
private static final String BEGIN_DATABASE_STRING
BEGIN_DRDAID_STRINGback to summary
private static final String BEGIN_DRDAID_STRING
BEGIN_EXECUTING_STRINGback to summary
private static final String BEGIN_EXECUTING_STRING
BEGIN_THREAD_STRINGback to summary
private static final String BEGIN_THREAD_STRING
BEGIN_XID_STRINGback to summary
private static final String BEGIN_XID_STRING
bufferedReaderback to summary
private BufferedReader bufferedReader
columnInfoback to summary
private static final ResultColumnDescriptor[] columnInfo
databaseIndexback to summary
private int databaseIndex
drdaidIndexback to summary
private int drdaidIndex
END_DATABASE_STRINGback to summary
private static final String END_DATABASE_STRING
END_DRDAID_STRINGback to summary
private static final String END_DRDAID_STRING
END_EXECUTING_STRINGback to summary
private static final String END_EXECUTING_STRING
END_THREAD_STRINGback to summary
private static final String END_THREAD_STRING
END_TIMESTAMPback to summary
private static final String END_TIMESTAMP
END_XID_STRINGback to summary
private static final String END_XID_STRING
endTimestampIndexback to summary
private int endTimestampIndex
gotFileback to summary
private boolean gotFile
inputFileNameback to summary
private String inputFileName
inputFileStreamReaderback to summary
private InputStreamReader inputFileStreamReader
inputStreamback to summary
private InputStream inputStream
lccidIndexback to summary
private int lccidIndex
lineback to summary
private String line
metadataback to summary
private static final ResultSetMetaData metadata
PARAMETERS_STRINGback to summary
private static final String PARAMETERS_STRING
threadIndexback to summary
private int threadIndex
xidIndexback to summary
private int xidIndex

Constructor Detail

ErrorLogReaderback 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.

ErrorLogReaderback to summary
public ErrorLogReader(String inputFileName) throws StandardException

Method Detail

closeback to summary
public void close()

Implements java.sql.ResultSet.close.

Doc from java.sql.ResultSet.close.

Releases this ResultSet object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed.

The closing of a ResultSet object does not close the Blob, Clob or NClob objects created by the ResultSet. Blob, Clob or NClob objects remain valid for at least the duration of the transaction in which they are created, unless their free method is invoked.

When a ResultSet is closed, any ResultSetMetaData instances that were created by calling the getMetaData method remain accessible.

Note

A ResultSet object is automatically closed by the Statement object that generated it when that Statement object is closed, re-executed, or is used to retrieve the next result from a sequence of multiple results.

Calling the method close on a ResultSet object that is already closed is a no-op.

See Also
java.sql.ResultSet#close
getMetaDataback to summary
public ResultSetMetaData getMetaData()

Overrides org.apache.derby.vti.VTITemplate.getMetaData.

Implements java.sql.ResultSet.getMetaData.

Doc from java.sql.ResultSet.getMetaData.

Retrieves the number, types and properties of this ResultSet object's columns.

Returns:ResultSetMetaData

the description of this ResultSet object's columns

See Also
java.sql.ResultSet#getMetaData
getStringback to summary
public String getString(int columnNumber) throws SQLException

Overrides org.apache.derby.vti.VTITemplate.getString.

Implements java.sql.ResultSet.getString.

All columns in the Db2jLogReader VTI have a of String type.

Parameters
columnNumber:int

Doc from java.sql.ResultSet.getString.

the first column is 1, the second is 2, ...

Returns:String

Doc from java.sql.ResultSet.getString.

the column value; if the value is SQL NULL, the value returned is null

Exceptions
SQLException:
If database-access error occurs.
See Also
java.sql.ResultSet#getString
nextback to summary
public boolean next() throws SQLException

Implements java.sql.ResultSet.next.

Doc from java.sql.ResultSet.next.

Moves the cursor forward one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.

When a call to the next method returns false, the cursor is positioned after the last row. Any invocation of a ResultSet method which requires a current row will result in a SQLException being thrown. If the result set type is TYPE_FORWARD_ONLY, it is vendor specified whether their JDBC driver implementation will return false or throw an SQLException on a subsequent call to next.

If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read.

Returns:boolean

true if the new current row is valid; false if there are no more rows

Exceptions
SQLException:
If database-access error occurs.
See Also
java.sql.ResultSet#next
wasNullback to summary
public boolean wasNull()

Overrides org.apache.derby.vti.VTITemplate.wasNull.

Implements java.sql.ResultSet.wasNull.

Doc from java.sql.ResultSet.wasNull.

Reports whether the last column read had a value of SQL NULL. Note that you must first call one of the getter methods on a column to try to read its value and then call the method wasNull to see if the value read was SQL NULL.

Returns:boolean

true if the last column value read was SQL NULL and false otherwise

See Also
java.sql.ResultSet#wasNull