01: /*
02: * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/lib/TKDBResultRowList.java,v 1.5 2000/05/22 15:01:19 careck Exp $
03: *
04: */
05: package com.teamkonzept.lib;
06:
07: import java.sql.*;
08:
09: /**
10: *
11: *
12: */
13: public class TKDBResultRowList extends TKVector implements
14: TKDBResultRow {
15:
16: protected boolean hasResult = false;
17: protected String colNames[] = null;
18:
19: /**
20: *
21: *
22: */
23: public TKDBResultRowList(ResultSet rs) {
24: this (rs, new TKDBResultInfo(rs));
25: }
26:
27: public TKDBResultRowList(ResultSet rs, TKDBResultInfo info) {
28: super (info.colCount);
29: this .colNames = info.colNames;
30: getResult(rs, info);
31: }
32:
33: public boolean getResult(ResultSet rs, TKDBResultInfo info) {
34: try {
35: if (!rs.next())
36: return false;
37: for (int i = 1; i <= info.colCount; i++) {
38: addElement(TKDBObjectCreator.getResultObject(rs, i,
39: info.colTypes[i - 1]));
40: }
41: hasResult = true;
42: return true;
43: } catch (SQLException ex) {
44: TKDBLogger.logSQLException(ex);
45: }
46: return false;
47: }
48:
49: public final boolean hasResult() {
50: return hasResult;
51: }
52:
53: public Object getColumn(String colName) {
54: for (int i = 0; i < colNames.length; i++) {
55: if (colName.equals(colNames[i])) {
56: return get(i);
57: }
58: }
59: return null;
60: }
61:
62: public Object getColumn(int colIdx) {
63: return get(colIdx);
64: }
65:
66: public String getColumnLabel(int colIdx) {
67: return colNames[colIdx];
68: }
69:
70: public int getColumnCount() {
71: return colNames.length;
72: }
73:
74: }
|