Advertisement
rahul0611

Load WorkGroups from Db

May 25th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. private static final String LOAD_WORKGROUP =
  2.             "SELECT jid, displayName, description, status, modes, creationDate, " +
  3.             "modificationDate, maxchats, minchats, offerTimeout, requestTimeout, " +
  4.             "schedule FROM fpWorkgroup WHERE workgroupID=?";
  5.  
  6.  private void loadWorkgroup() {
  7.         Connection con = null;
  8.         PreparedStatement pstmt = null;
  9.         ResultSet rs = null;
  10.         try {
  11.             con = DbConnectionManager.getConnection();
  12.             pstmt = con.prepareStatement(LOAD_WORKGROUP);
  13.  
  14.             pstmt.setLong(1, id);
  15.             rs = pstmt.executeQuery();
  16.             if (rs.next()) {
  17.                 workgroupName = rs.getString(1);
  18.                 if (rs.getString(2) != null && rs.getString(2).length() > 0) {
  19.                     displayName = rs.getString(2);
  20.                 }
  21.                 else {
  22.                     displayName = workgroupName;
  23.                 }
  24.                 description = rs.getString(3);
  25.                 open = rs.getInt(4) == 1;
  26.                 followSchedule = rs.getInt(5) == 1;
  27.                 creationDate = new Date(Long.parseLong(rs.getString(6).trim()));
  28.                 modDate = new Date(Long.parseLong(rs.getString(7).trim()));
  29.                 maxChats = rs.getInt(8);
  30.                 minChats = rs.getInt(9);
  31.                 offerTimeout = rs.getInt(10);
  32.                 requestTimeout = rs.getInt(11);
  33.                 schedule = new Schedule(id, rs.getString(12));
  34.             }
  35.         }
  36.         catch (SQLException ex) {
  37.             Log.error(ex.getMessage(), ex);
  38.         }
  39.         finally {
  40.             DbConnectionManager.closeConnection(rs, pstmt, con);
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement