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.data;
07:
08: import java.sql.*;
09: import com.lutris.appserver.server.Enhydra;
10: import com.lutris.appserver.server.sql.*;
11: import java.util.Vector;
12:
13: public class SimpleDiscQuery {
14: DBConnection connection;
15:
16: public SimpleDiscQuery() {
17: try {
18: connection = Enhydra.getDatabaseManager()
19: .allocateConnection();
20:
21: } catch (Exception e) {
22: e.printStackTrace();
23: }
24: }
25:
26: public Vector query() {
27: ResultSet resultSet = null;
28: Vector vResultSet = new Vector();
29:
30: try {
31: resultSet = connection
32: .executeQuery("SELECT * FROM LE_TUTORIAL_DISCS");
33: int i = 0;
34: if (resultSet != null) {
35: while (resultSet.next()) {
36: Vector vRow = new Vector(4);
37: vRow.addElement(resultSet.getString("artist"));
38: vRow.addElement(resultSet.getString("title"));
39: vRow.addElement(resultSet.getString("genre"));
40: vRow.addElement(Integer.toString(resultSet
41: .getInt("isLiked")));
42: vResultSet.addElement(vRow);
43: }
44: }
45: connection.reset();
46: connection.release();
47:
48: } catch (Exception e) {
49: e.printStackTrace();
50: }
51:
52: return vResultSet;
53: }
54:
55: }
|