Examples of ForumMessageNotFoundException


Examples of org.nemesis.forum.exception.ForumMessageNotFoundException

      con = DbConnectionManager.getConnection();
      pstmt = con.prepareStatement(LOAD_MESSAGE);
      pstmt.setInt(1, id);
      ResultSet rs = pstmt.executeQuery();
      if (!rs.next()) {
        throw new ForumMessageNotFoundException("Message " + id + " could not be loaded from the database.");
      }
      //Get the query results. We use int indexes into the ResultSet
      //because it is slightly faster. Care should be taken so that the
      //SQL query is not modified without modifying these indexes.
      this.userID = rs.getInt(1);
      //We trim() the dates before trying to parse them because some
      //databases pad with extra characters when returning the data.
      this.creationDate = new java.util.Date(Long.parseLong(rs.getString(2).trim()));
      this.modifiedDate = new java.util.Date(Long.parseLong(rs.getString(3).trim()));
      this.subject = rs.getString(4);
      this.body = rs.getString(5);
      this.threadID = rs.getInt(6);
      this.approved= rs.getInt(7)==1;
    } catch (SQLException sqle) {
      throw new ForumMessageNotFoundException("Message of id " + id + " was not found in the database.");
    } catch (NumberFormatException nfe) {
      log.error(
        "WARNING: In DbForumMessage.loadFromDb() -- there "
          + "was an error parsing the dates returned from the database. Ensure "
          + "that they're being stored correctly.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.