Advertisement
rahul0611

Load Agents from DB

May 25th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1.  private static final String LOAD_AGENTS =
  2.             "SELECT agentID FROM fpAgent";
  3.  
  4.  private void loadAgents() {
  5.         Connection con = null;
  6.         PreparedStatement pstmt = null;
  7.         ResultSet rs = null;
  8.         try {
  9.             con = DbConnectionManager.getConnection();
  10.             pstmt = con.prepareStatement(LOAD_AGENTS);
  11.             rs = pstmt.executeQuery();
  12.             while (rs.next()) {
  13.                 final Agent agent = new Agent(rs.getLong(1));
  14.                 agents.put(agent.getAgentJID().toBareJID(), agent);
  15.             }
  16.         }
  17.         catch (Exception ex) {
  18.             Log.error(ex.getMessage(), ex);
  19.         }
  20.         finally {
  21.             DbConnectionManager.closeConnection(rs, pstmt, con);
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement