01: /*
02: This file is part of the Tutorial chapter of "Getting Started with Enhydra".
03: It is not meant to be used in any other context.
04: */
05:
06: package simpleapp.business;
07:
08: import simpleapp.data.SimpleDiscQuery;
09: import java.util.*;
10:
11: public class SimpleDiscList {
12: SimpleDiscQuery _sdq;
13:
14: public SimpleDiscList() {
15: try {
16: _sdq = new SimpleDiscQuery();
17:
18: } catch (Exception e) {
19: e.printStackTrace();
20: }
21: }
22:
23: /* Method to return a 2-dimensional array of strings representing
24: a result set from the Disc Table.
25: */
26: public String[][] getDiscList() {
27: try {
28:
29: Vector vResults = _sdq.query();
30: if (vResults == null) {
31: System.out.println("vResults is null");
32: }
33: String result[][] = new String[vResults.size()][4];
34: int i = 0;
35:
36: Enumeration eResult = vResults.elements();
37: while (eResult.hasMoreElements()) {
38: Vector vRow = (Vector) eResult.nextElement();
39: result[i][0] = (String) vRow.elementAt(0);
40: result[i][1] = (String) vRow.elementAt(1);
41: result[i][2] = (String) vRow.elementAt(2);
42: result[i][3] = ((((String) vRow.elementAt(3))
43: .equals("0")) ? "No" : "Yes");
44: i++;
45: }
46: return result;
47:
48: } catch (Exception e) {
49: e.printStackTrace();
50: }
51:
52: return null;
53:
54: } //getDiscList
55:
56: }
|