Examples of SQLiteStatement


Examples of com.almworks.sqlite4java.SQLiteStatement

    if (champions == null) {
      SQLiteQueue queue = GameStatsDBWrapper.getQueue();
      champions = new LinkedList<Champion>();
      queue.execute(new SQLiteJob<Object>() {
        protected Object job(SQLiteConnection connection) throws Throwable {
          SQLiteStatement st = connection
              .prepare("SELECT * FROM champions");
          while (st.step()) {
            Champion newChamp = new Champion();
            int i = 0; // first column is id
            newChamp.ID = st.columnInt(i); i++;
            newChamp.name = st.columnString(i); i++;
            newChamp.displayName = st.columnString(i); i++;
            newChamp.title = st.columnString(i); i++;
            newChamp.iconPath = st.columnString(i); i++;
            newChamp.portraitPath = st.columnString(i); i++;
            newChamp.splashPath = st.columnString(i); i++;
            newChamp.danceVideoPath = st.columnString(i); i++; i++; // TODO: tags
            newChamp.description = st.columnString(i); i++;
            newChamp.quote = st.columnString(i); i++;
            newChamp.quoteAuthor = st.columnString(i); i++;
            newChamp.range = st.columnInt(i); i++;
            newChamp.movementSpeed = st.columnInt(i); i++;
            newChamp.armorBase = st.columnDouble(i); i++;
            newChamp.armorLevel = st.columnDouble(i); i++;
            newChamp.manaBase = st.columnInt(i); i++;
            newChamp.manaLevel = st.columnInt(i); i++;
            newChamp.criticalChanceBase = st.columnInt(i); i++;
            newChamp.criticalChanceLevel = st.columnInt(i); i++;
            newChamp.manaRegenBase = st.columnDouble(i); i++;
            newChamp.manaRegenLevel = st.columnDouble(i); i++;
            newChamp.healthRegenBase = st.columnDouble(i); i++;
            newChamp.healthRegenLevel = st.columnDouble(i); i++;
            newChamp.magicResistBase = st.columnInt(i); i++;
            newChamp.magicResistLevel = st.columnDouble(i); i++;
            newChamp.healthBase = st.columnInt(i); i++;
            newChamp.healthLevel = st.columnDouble(i); i++;
            newChamp.attackBase = st.columnDouble(i); i++;
            newChamp.attackLevel = st.columnDouble(i); i++;
            newChamp.ratingAttack = st.columnInt(i); i++;
            newChamp.ratingDefense = st.columnInt(i); i++;
            newChamp.ratingDifficulty = st.columnInt(i); i++;
            newChamp.ratingMagic = st.columnInt(i); i++;
            newChamp.tips = st.columnString(i); i++;
            newChamp.opponentTips = st.columnString(i); i++;
            newChamp.selectSoundPath = st.columnString(i); i++;
 
            SQLiteStatement skinsDB = connection
                .prepare("SELECT * FROM championskins WHERE championId = ?");
            skinsDB.bind(1, newChamp.ID);
            while (skinsDB.step()) {
              ChampionSkin theSkin = new ChampionSkin();
              i = 0;
              theSkin.ID = skinsDB.columnInt(i); i++;
              theSkin.isDefault = skinsDB.columnInt(i) == 1; i++;
              theSkin.order = skinsDB.columnInt(i); i++;
              theSkin.championID = skinsDB.columnInt(i); i++;
              theSkin.name = skinsDB.columnString(i); i++;
              theSkin.displayName = skinsDB.columnString(i); i++;
              theSkin.portraitPath = skinsDB.columnString(i); i++;
              theSkin.splashPath = skinsDB.columnString(i); i++;
              newChamp.skins.add(theSkin);
            }
            skinsDB.dispose();
 
            /*
             * SQLiteStatement itemsDB = connection.prepare(
             * "SELECT * FROM championitems WHERE championId = ?");
             * itemsDB.bind(1, newChamp.ID); while (itemsDB.step()) {
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

    SQLiteQueue queue = GameStatsDBWrapper.getQueue();
    items = new LinkedList<Item>();
    queue.execute(new SQLiteJob<Object>() {
      protected Object job(SQLiteConnection connection) throws Throwable {
        SQLiteStatement st = connection.prepare("SELECT * FROM items");
        while (st.step()) {
          Item newItem = new Item();
          int i = 0;
          newItem.ID = st.columnInt(i);
          i++;
          newItem.name = st.columnString(i);
          i++;
          newItem.description = st.columnString(i);
          i++;
          newItem.iconPath = st.columnString(i);
          i++;
          newItem.price = st.columnInt(i);
          i++;
          newItem.flatHPPoolMod = st.columnInt(i);
          i++;
          newItem.flatMPPoolMod = st.columnInt(i);
          i++;
          newItem.percentHPPoolMod = st.columnInt(i);
          i++;
          newItem.percentMPPoolMod = st.columnInt(i);
          i++;
          newItem.flatHPRegenMod = st.columnInt(i);
          i++;
          newItem.percentHPRegenMod = st.columnInt(i);
          i++;
          newItem.flatMPRegenMod = st.columnInt(i);
          i++;
          newItem.percentMPRegenMod = st.columnInt(i);
          i++;
          newItem.flatArmorMod = st.columnInt(i);
          i++;
          newItem.percentArmorMod = st.columnInt(i);
          i++;
          newItem.flatAttackDamageMod = st.columnInt(i);
          i++;
          newItem.percentAttackDamageMod = st.columnInt(i);
          i++;
          newItem.flatAbilityPowerMod = st.columnInt(i);
          i++;
          newItem.percentAbilityPowerMod = st.columnInt(i);
          i++;
          newItem.flatMovementSpeedMod = st.columnInt(i);
          i++;
          newItem.percentMovementSpeedMod = st.columnInt(i);
          i++;
          newItem.flatAttackSpeedMod = st.columnInt(i);
          i++;
          newItem.percentAttackSpeedMod = st.columnInt(i);
          i++;
          newItem.flatDodgeMod = st.columnInt(i);
          i++;
          newItem.percentDodgeMod = st.columnInt(i);
          i++;
          newItem.flatCritChanceMod = st.columnInt(i);
          i++;
          newItem.percentCritChanceMod = st.columnInt(i);
          i++;
          newItem.flatCritDamageMod = st.columnInt(i);
          i++;
          newItem.percentCritDamageMod = st.columnInt(i);
          i++;
          newItem.flatMagicResistMod = st.columnInt(i);
          i++;
          newItem.percentMagicResistMod = st.columnInt(i);
          i++;
          newItem.flatEXPBonus = st.columnInt(i);
          i++;
          newItem.percentEXPBonus = st.columnInt(i);
          i++;
          newItem.epicness = st.columnInt(i);
          i++;
          items.add(newItem);
        }
        st.dispose();

        // TODO: add all legacy items
        items.add(new Item(0, "Empty", "EmptyIcon.png"));
        items.add(new Item(1005, "Meki Pendant",
            "3013_Disruption_Rod.png"));
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  // Manage Hive Support
  ///////////////////////////////////////////////
  public String checkHiveSupport(final Path fpath) {
    return dbQueue.execute(new SQLiteJob<String>() {
        protected String job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT hiveTableName FROM HiveTables WHERE fpath = ?");
          try {
            stmt.bind(1, fpath.toString());
            while (stmt.step()) {
              return stmt.columnString(0);
            }
            return null;
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

      }).complete();
  }
  public void addHiveSupport(final Path fpath, final String tablename) {
    dbQueue.execute(new SQLiteJob<Object>() {
        protected Object job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("INSERT into HiveTables VALUES(?, ?)");
          try {
            stmt.bind(1, fpath.toString());
            stmt.bind(2, tablename);
            stmt.step();
            return null;
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

    // REMIND -- must check to make sure FS is valid before accepting it.
    // (E.g., for HDFS see if we can contact it)
   
    long fsid = dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT fsid FROM Filesystems WHERE fsname = ?");
          try {
            stmt.bind(1, fsuri.toString());
            if (stmt.step()) {
              long resultId = stmt.columnLong(0);
              return resultId;
            } else {
              return -1L;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
    if (fsid >= 0) {
      return fsid;
    }

    // It wasn't there, so create it!
    if (canCreate) {
      return dbQueue.execute(new SQLiteJob<Long>() {
          protected Long job(SQLiteConnection db) throws SQLiteException {
            SQLiteStatement stmt = db.prepare("INSERT into Filesystems VALUES(null, ?)");
            try {
              stmt.bind(1, fsuri.toString());
              stmt.step();
              return db.getLastInsertId();
            } finally {
              stmt.dispose();
            }
          }
        }).complete();
    } else {
      return -1L;
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * If no crawl is pending, a new one is created.
   */
  public long getCreatePendingCrawl(final long fsid, boolean shouldCreate)  {
      long crawlid = dbQueue.execute(new SQLiteJob<Long>() {
          protected Long job(SQLiteConnection db) throws SQLiteException {
            SQLiteStatement stmt = db.prepare("SELECT crawlid from Crawls WHERE fsid = ? AND inprogress = 'True'");
            try {
              stmt.bind(1, fsid);
              if (stmt.step()) {
                return stmt.columnLong(0);
              } else {
                return -1L;
              }
            } finally {
              stmt.dispose();
            }
          }
        }).complete();

      if (crawlid >= 0) {
        return crawlid;
      }
   
      // Time to insert
      if (shouldCreate) {
        return dbQueue.execute(new SQLiteJob<Long>() {
            protected Long job(SQLiteConnection db) throws SQLiteException {
              Date now = new Date(System.currentTimeMillis());
              String dateCreated = fileDateFormat.format(now);
              String syntheticDateFinished = fileDateFormat.format(new Date(0));
              String inprogress = "True";
              SQLiteStatement stmt = db.prepare("INSERT into Crawls VALUES(null, ?, ?, ?, ?)");
              try {
                stmt.bind(1, dateCreated).bind(2, syntheticDateFinished).bind(3, inprogress).bind(4, fsid);
                stmt.step();
                return db.getLastInsertId();
              } finally {
                stmt.dispose();
              }
            }
          }).complete();
      }
    return -1L;
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  }
 
  public void completeCrawl(final long crawlid) throws SQLiteException {
    dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("UPDATE Crawls SET inprogress='False', crawlfinished=? WHERE crawlid = ?");
          try {
            Date now = new Date(System.currentTimeMillis());
            String dateFinished = fileDateFormat.format(now);
            stmt.bind(1, dateFinished).bind(2, crawlid);
            if (stmt.step()) {
              return crawlid;
            } else {
              return -1L;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

  }

  public long getLatestCompleteCrawl(final long fsid) {
    return dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT crawlid from Crawls WHERE fsid = ? AND inprogress = 'False' ORDER BY crawlid DESC LIMIT 1");
          try {
            stmt.bind(1, fsid);
            if (stmt.step()) {
              return stmt.columnLong(0);
            } else {
              return -1L;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

   * The row is created, if necessary.
   */
  long getCreateType(final String typeLabel) throws SQLiteException {
    long typeid = dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("SELECT typeid FROM Types WHERE typelabel = ?");
          try {
            stmt.bind(1, typeLabel);
            if (stmt.step()) {
              long resultId = stmt.columnLong(0);
              return resultId;
            } else {
              return -1L;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();

    if (typeid >= 0) {
      return typeid;
    }
   
    // Time to insert
    return dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          SQLiteStatement stmt = db.prepare("INSERT into Types VALUES(null, ?)");
          try {
            stmt.bind(1, typeLabel);
            stmt.step();
            return db.getLastInsertId();
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here

Examples of com.almworks.sqlite4java.SQLiteStatement

    final String schemaIdentifier = (sd == null) ? "" : sd.getSchemaIdentifier();
    final String schemaDesc = (sd == null) ? "no schema" : sd.getSchemaSourceDescription();
    final byte[] payload = (sd == null) ? new byte[0] : sd.getPayload();
    long schemaid = dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          final SQLiteStatement stmt = db.prepare("SELECT schemaid FROM Schemas WHERE schemarepr = ? AND schemasrcdescription = ?");
          try {
            stmt.bind(1, schemaIdentifier).bind(2, schemaDesc);
            if (stmt.step()) {
              long resultId = stmt.columnLong(0);
              return resultId;
            } else {
              return -1L;
            }
          } finally {
            stmt.dispose();
          }
        }
      }).complete();

    if (schemaid >= 0) {
      return schemaid;
    }
   
    // Time to insert
    return dbQueue.execute(new SQLiteJob<Long>() {
        protected Long job(SQLiteConnection db) throws SQLiteException {
          final SQLiteStatement stmt = db.prepare("INSERT into Schemas VALUES(null, ?, ?, ?)");
          try {
            stmt.bind(1, schemaIdentifier).bind(2, schemaDesc).bind(3, payload);
            stmt.step();
            return db.getLastInsertId();     
          } finally {
            stmt.dispose();
          }
        }
      }).complete();
  }
View Full Code Here
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.