Exemplo n.º 1
0
 public Vector<Message> getInboxMessages(String username, int type) {
   if (type == 4) username = "******";
   ResultSet rs =
       con.queryDB(
           "SELECT * FROM "
               + MESSAGES
               + " WHERE toName = \""
               + username
               + "\" AND messageType = "
               + type
               + " ORDER BY timeStamp DESC");
   Vector<Message> inbox = new Vector<Message>();
   try {
     while (rs.next()) {
       inbox.add(
           new Message(
               rs.getString("fromName"),
               username,
               rs.getString("message"),
               rs.getInt("messageType"),
               rs.getTimestamp("timeStamp")));
     }
   } catch (SQLException e) {
     throw new RuntimeException("SQLException in MessageDatabase::getInboxMessages");
   }
   return inbox;
 }
Exemplo n.º 2
0
 public boolean containsFriendRequest(String from, String to) {
   ResultSet rs =
       con.queryDB(
           "SELECT * FROM "
               + MESSAGES
               + " WHERE fromName = \""
               + from
               + "\" AND toName = \""
               + to
               + "\" AND messageType = 2");
   try {
     if (rs.next()) return true;
   } catch (SQLException e) {
     throw new RuntimeException("SQLException in MessageDatabase::containsFriendRequest");
   }
   return false;
 }
Exemplo n.º 3
0
 /*
  * Returns a Vector representing all messages in the user's outbox.  The most recent
  * messages are at the beginning, and the oldest ones are at the end.
  */
 public Vector<Message> getOutboxMessages(String username) {
   ResultSet rs =
       con.queryDB(
           "SELECT * FROM "
               + MESSAGES
               + " WHERE fromName = \""
               + username
               + "\" ORDER BY timeStamp DESC");
   Vector<Message> outbox = new Vector<Message>();
   try {
     while (rs.next()) {
       outbox.add(
           new Message(
               username,
               rs.getString("toName"),
               rs.getString("message"),
               rs.getInt("messageType"),
               rs.getTimestamp("timeStamp")));
     }
   } catch (SQLException e) {
     throw new RuntimeException("SQLException in MessageDatabase::getOutboxMessages");
   }
   return outbox;
 }