Package marauroa.server.db

Examples of marauroa.server.db.DBTransaction


   * @param charname name of char
   * @return buddy list
   * @throws SQLException in case of an database error
   */
  public Set<String> loadBuddyList(String charname) throws SQLException {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      return loadBuddyList(transaction, charname);
    } finally {
      TransactionPool.get().commit(transaction);
    }
View Full Code Here


   * @param charname name of char
   * @param buddies buddy list
   * @throws SQLException in case of an database error
   */
  public void saveBuddyList(String charname, Set<String> buddies) throws SQLException {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      saveBuddyList(transaction, charname, buddies);
    } finally {
      TransactionPool.get().commit(transaction);
    }
View Full Code Here

   *
   * @param timedate date when to start
   */
  public boolean analyse(final String timedate) {
    boolean okay = true;
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      final Iterator<GameEventEntry> itr = queryDatabase(transaction, timedate);
      while (itr.hasNext()) {
        final GameEventEntry entry = itr.next();
        if (entry.getEvent().equals("login")) {
View Full Code Here

    final ResultSet resultSet = transaction.query(SQL, params);
    return new LogEntryIterator(resultSet);
  }
 
  public void analyse(final String timedate) {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      final Iterator<LogEntry> itr = queryDatabase(transaction, timedate);
      ItemInfo oldItemInfo = new ItemInfo();
      while (itr.hasNext()) {
        final LogEntry entry = itr.next();
View Full Code Here

    }
    System.exit(0);
  }

  private void logTransfer(ItemInfo oldItemInfo, ItemInfo itemInfo, LogEntry entry) {
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      String query = "INSERT INTO itemtransfer_analyse (itemid, name, quantity, giver, receiver, oldid) VALUES ([itemid], '[name]', '[quantity]', '[giver]', '[receiver]', [oldid]);";
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("itemid", oldItemInfo.getItemid());
      params.put("name", oldItemInfo.getName());
      params.put("quantity", itemInfo.getQuantity());
      params.put("giver", oldItemInfo.getOwner());
      params.put("receiver", itemInfo.getOwner());
      params.put("oldid", entry.getId());
     
      transaction.execute(query, params);
      //System.out.println(itemInfo + " " + oldItemInfo.getOwner() + " " + itemInfo.getOwner());

      TransactionPool.get().commit(transaction);
    } catch (Exception e) {
      TransactionPool.get().rollback(transaction);
View Full Code Here

   
    for (int i = 1122; i < 346000; i++) {
      System.out.println("> " + i);
      String cmd = "INSERT INTO itemlog_new (id, timedate, itemid, source, event, param1, param2, param3, param4)"
        + " SELECT id, timedate, itemid, source, event, param1, param2, param3, param4 FROM itemlog WHERE id >= " + (i * 100) + " AND id < "  + ((i+1) * 100);
      DBTransaction transaction = transactionPool.beginWork();
      transaction.execute(cmd, null);
      transactionPool.commit(transaction);
      System.out.println("< " + i);
      Thread.sleep(3000);
    }
  }
View Full Code Here

        continue;
      }
      cmd.append(" " + line);
     
      if (cmd.indexOf(";") > -1) {
        DBTransaction transaction = transactionPool.beginWork();
        try {
          if (cmd.indexOf("DROP TABLE") != 0 && cmd.indexOf("CREATE TABLE") != 0) {
            transaction.execute(line, null);
          }
        } catch (SQLException e) {
          logger.error(cmd, e);
        }
        transactionPool.commit(transaction);
View Full Code Here

   * Tests for doUpdate.
   */
  @Test
  public void testDoUpdate() throws Exception, Throwable {
    MockStendlRPWorld.get();
    DBTransaction transaction = TransactionPool.get().beginWork();
    try {
      PlayerModifier pm = new PlayerModifier();
      Player loaded = pm.loadPlayer(transaction, "george");
      assertNotNull("pm can only handle existing players, so if this fails first create a player called george in db by login", loaded);
      if (loaded.getSlot("bag").size() > 0) {
View Full Code Here

    if (result != null) {
      return new CharacterResult(result, character, template);
    }

    final TransactionPool transactionPool = SingletonRepository.getTransactionPool();
    final DBTransaction trans = transactionPool.beginWork();
    final CharacterDAO characterDAO = DAORegister.get().get(CharacterDAO.class);

    try {
      if (characterDAO.hasCharacter(trans, character)) {
        logger.warn("Character already exist: " + character);
View Full Code Here

   *
   * @return Result.OK_CREATED on success
   */
  private AccountResult insertIntoDatabase() {
    final TransactionPool transactionPool = SingletonRepository.getTransactionPool();
    final DBTransaction transaction = transactionPool.beginWork();
    final AccountDAO accountDAO = DAORegister.get().get(AccountDAO.class);

    try {
      if (accountDAO.hasPlayer(transaction, username)) {
        logger.warn("Account already exist: " + username);
View Full Code Here

TOP

Related Classes of marauroa.server.db.DBTransaction

Copyright © 2018 www.massapicom. 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.