SHARE
TWEET

Untitled

a guest Nov 22nd, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private ItemAuction loadAuction(int auctionId) throws SQLException
  2.     {
  3.         try (Connection con = DatabaseFactory.getInstance().getConnection())
  4.         {
  5.             PreparedStatement statement = con.prepareStatement("SELECT auctionItemId,startingTime,endingTime,auctionStateId FROM item_auction WHERE auctionId=?");
  6.             statement.setInt(1, auctionId);
  7.             ResultSet rset = statement.executeQuery();
  8.  
  9.             if (!rset.next())
  10.             {
  11.                 _log.warn("ItemAuction: Auction data not found for auction: " + auctionId);
  12.                 return null;
  13.             }
  14.            
  15.             int auctionItemId = rset.getInt(1);
  16.             long startingTime = rset.getLong(2);
  17.             long endingTime = rset.getLong(3);
  18.             int auctionStateId = rset.getInt(4);
  19.            
  20.             DbUtils.close(statement, rset);
  21.        
  22.            
  23.             if (startingTime >= endingTime)
  24.             {
  25.                 _log.warn("ItemAuction: Invalid starting/ending paramaters for auction: " + auctionId);
  26.                 return null;
  27.             }
  28.            
  29.             AuctionItem auctionItem = getAuctionItem(auctionItemId);
  30.             if (auctionItem == null)
  31.             {
  32.                 _log.warn("ItemAuction: AuctionItem: " + auctionItemId + ", not found for auction: " + auctionId);
  33.                 return null;
  34.             }
  35.            
  36.             ItemAuctionState auctionState = ItemAuctionState.stateForStateId(auctionStateId);
  37.             if (auctionState == null)
  38.             {
  39.                 _log.warn("ItemAuction: Invalid auctionStateId: " + auctionStateId + ", for auction: " + auctionId);
  40.                 return null;
  41.             }
  42.            
  43.             ItemAuction auction = new ItemAuction(auctionId, _instanceId, startingTime, endingTime, auctionItem, auctionState);
  44.            
  45.             statement = con.prepareStatement("SELECT playerObjId,playerBid FROM item_auction_bid WHERE auctionId=?");
  46.             statement.setInt(1, auctionId);
  47.             rset = statement.executeQuery();
  48.            
  49.             while (rset.next())
  50.             {
  51.                 int charId = rset.getInt(1);
  52.                 long playerBid = rset.getLong(2);
  53.                 ItemAuctionBid bid = new ItemAuctionBid(charId, playerBid);
  54.                 auction.addBid(bid);
  55.             }
  56.            
  57.             return auction;
  58.         }
  59.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top