KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > simpleapp > data > SimpleDiscQuery


1 /*
2     This file is part of the Tutorial chapter of "Getting Started with Enhydra".
3     It is not meant to be used in any other context.
4 */

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