Package games.stendhal.tools.copytable

Source Code of games.stendhal.tools.copytable.CopyTable

/* $Id: CopyTable.java,v 1.3 2010/09/19 01:29:09 nhnb Exp $ */
/***************************************************************************
*                   (C) Copyright 2003-2010 - Stendhal                    *
***************************************************************************
***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/
package games.stendhal.tools.copytable;

import java.sql.SQLException;

import marauroa.server.db.DBTransaction;
import marauroa.server.db.TransactionPool;
import marauroa.server.game.db.DatabaseFactory;

public class CopyTable {

  public static void main(String[] args) throws SQLException, InterruptedException {
    new DatabaseFactory().initializeDatabase();
    TransactionPool transactionPool = TransactionPool.get();
   
    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);
    }
  }
}
TOP

Related Classes of games.stendhal.tools.copytable.CopyTable

TOP
Copyright © 2018 www.massapi.com. 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.