KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > logging > JdbcResultSetEvent


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc.logging;
13
14 import java.sql.ResultSet JavaDoc;
15 import java.sql.Statement JavaDoc;
16 import java.sql.SQLException JavaDoc;
17 import java.util.List JavaDoc;
18 import java.util.Arrays JavaDoc;
19
20 /**
21  * An JDBC ResultSet related event.
22  * @keep-all
23  */

24 public class JdbcResultSetEvent extends JdbcLogEvent {
25
26     private int statementID;
27     private int resultSetID;
28     private boolean next;
29     private Object JavaDoc[] row;
30     private int rows;
31
32     public JdbcResultSetEvent(long txId, ResultSet JavaDoc rs, String JavaDoc descr, int type) {
33         super(txId, type, descr);
34         this.resultSetID = System.identityHashCode(rs);
35         try {
36             Statement JavaDoc s = rs.getStatement();
37             if (s != null) statementID = System.identityHashCode(s);
38         } catch (SQLException JavaDoc e) {
39             // ignore
40
}
41     }
42
43     /**
44      * Get a long description for this event (e.g. the query text).
45      */

46     public String JavaDoc getDescription() {
47         StringBuffer JavaDoc s = new StringBuffer JavaDoc();
48         if (descr != null) {
49             s.append(descr);
50             s.append(' ');
51         }
52         if (row != null) {
53             s.append('[');
54             int n = row.length;
55             for (int i = 0; i < n; i++) {
56                 if (i > 0) s.append(", ");
57                 s.append(row[i]);
58             }
59             s.append(']');
60         }
61         return s.toString();
62     }
63
64     public int getStatementID() {
65         return statementID;
66     }
67
68     public void setStatementID(int statementID) {
69         this.statementID = statementID;
70     }
71
72     public int getResultSetID() {
73         return resultSetID;
74     }
75
76     public void setResultSetID(int resultSetID) {
77         this.resultSetID = resultSetID;
78     }
79
80     public boolean isNext() {
81         return next;
82     }
83
84     public void setNext(boolean next) {
85         this.next = next;
86     }
87
88     public Object JavaDoc[] getRow() {
89         return row;
90     }
91
92     public void setRow(Object JavaDoc[] row) {
93         this.row = row;
94     }
95
96     public List JavaDoc getRowList() {
97         return Arrays.asList(row);
98     }
99
100     public int getRows() {
101         return rows;
102     }
103
104     public void setRows(int rows) {
105         this.rows = rows;
106     }
107
108     public int getResourceID() {
109         return statementID;
110     }
111 }
112
113
Popular Tags