001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.jdbc.logging;
012:
013: import java.sql.ResultSet;
014: import java.sql.Statement;
015: import java.sql.SQLException;
016: import java.util.List;
017: import java.util.Arrays;
018:
019: /**
020: * An JDBC ResultSet related event.
021: * @keep-all
022: */
023: public class JdbcResultSetEvent extends JdbcLogEvent {
024:
025: private int statementID;
026: private int resultSetID;
027: private boolean next;
028: private Object[] row;
029: private int rows;
030:
031: public JdbcResultSetEvent(long txId, ResultSet rs, String descr,
032: int type) {
033: super (txId, type, descr);
034: this .resultSetID = System.identityHashCode(rs);
035: try {
036: Statement s = rs.getStatement();
037: if (s != null)
038: statementID = System.identityHashCode(s);
039: } catch (SQLException e) {
040: // ignore
041: }
042: }
043:
044: /**
045: * Get a long description for this event (e.g. the query text).
046: */
047: public String getDescription() {
048: StringBuffer s = new StringBuffer();
049: if (descr != null) {
050: s.append(descr);
051: s.append(' ');
052: }
053: if (row != null) {
054: s.append('[');
055: int n = row.length;
056: for (int i = 0; i < n; i++) {
057: if (i > 0)
058: s.append(", ");
059: s.append(row[i]);
060: }
061: s.append(']');
062: }
063: return s.toString();
064: }
065:
066: public int getStatementID() {
067: return statementID;
068: }
069:
070: public void setStatementID(int statementID) {
071: this .statementID = statementID;
072: }
073:
074: public int getResultSetID() {
075: return resultSetID;
076: }
077:
078: public void setResultSetID(int resultSetID) {
079: this .resultSetID = resultSetID;
080: }
081:
082: public boolean isNext() {
083: return next;
084: }
085:
086: public void setNext(boolean next) {
087: this .next = next;
088: }
089:
090: public Object[] getRow() {
091: return row;
092: }
093:
094: public void setRow(Object[] row) {
095: this .row = row;
096: }
097:
098: public List getRowList() {
099: return Arrays.asList(row);
100: }
101:
102: public int getRows() {
103: return rows;
104: }
105:
106: public void setRows(int rows) {
107: this .rows = rows;
108: }
109:
110: public int getResourceID() {
111: return statementID;
112: }
113: }
|