Advertisement
rahul0611

Load Queue From DB

May 25th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1.  private static final String LOAD_QUEUE =
  2.             "SELECT name, description, priority, maxchats, minchats, overflow, backupQueue FROM " +
  3.             "fpQueue WHERE queueID=?";
  4.  
  5.  private void loadQueue() {
  6.         Connection con = null;
  7.         PreparedStatement pstmt = null;
  8.         ResultSet rs = null;
  9.         try {
  10.             con = DbConnectionManager.getConnection();
  11.             pstmt = con.prepareStatement(LOAD_QUEUE);
  12.             pstmt.setLong(1, id);
  13.             rs = pstmt.executeQuery();
  14.             rs.next();
  15.             name = rs.getString(1);
  16.             address = new JID(workgroup.getJID().getNode(), workgroup.getJID().getDomain(), name);
  17.             description = rs.getString(2);
  18.             priority = rs.getInt(3);
  19.             maxChats = rs.getInt(4);
  20.             minChats = rs.getInt(5);
  21.             switch (rs.getInt(6)) {
  22.                 case 1:
  23.                     overflowType = OverflowType.OVERFLOW_RANDOM;
  24.                     break;
  25.                 case 2:
  26.                     overflowType = OverflowType.OVERFLOW_BACKUP;
  27.                     break;
  28.                 default:
  29.                     overflowType = OverflowType.OVERFLOW_NONE;
  30.             }
  31.             backupQueueID = rs.getLong(7);
  32.  
  33.         }
  34.         catch (SQLException e) {
  35.             Log.error(e.getMessage(), e);
  36.         }
  37.         finally {
  38.             DbConnectionManager.closeConnection(rs, pstmt, con);
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement