Package lib.PatPeter.SQLibrary

Examples of lib.PatPeter.SQLibrary.Database.query()


      public void run() {
        synchronized (dbLock) {
          try {
            final Database db = (Database) DatabaseStorage.this.db;
            if (db != null)
              db.query("SELECT * FROM " + TABLE_NAME + " LIMIT 1");
          } catch (final SQLException e) {}
        }
      }
    };
    Skript.closeOnDisable(keepAlive);
View Full Code Here


    try {
      final boolean hasOldTable = db.isTable(OLD_TABLE_NAME);
      final boolean hadNewTable = db.isTable(TABLE_NAME);
     
      try {
        db.query(type.createQuery);
      } catch (final SQLException e) {
        Skript.error("Could not create the variables table in the database '" + databaseName + "': " + e.getLocalizedMessage() + ". "
            + "Please create the table yourself using the following query: " + type.createQuery.replace(",", ", ").replaceAll("\\s+", " "));
        return false;
      }
View Full Code Here

        return false;
      }
     
      // old
      if (hasOldTable) {
        final ResultSet r1 = db.query("SELECT " + SELECT_ORDER + " FROM " + OLD_TABLE_NAME);
        assert r1 != null;
        try {
          oldLoadVariables(r1);
        } finally {
          r1.close();
View Full Code Here

          r1.close();
        }
      }
     
      // new
      final ResultSet r2 = db.query("SELECT " + SELECT_ORDER + " FROM " + TABLE_NAME);
      assert r2 != null;
      try {
        loadVariables(r2);
      } finally {
        r2.close();
View Full Code Here

            Skript.info("Updated and transferred " + Variables.getVariablesHashMap().size() + " variables to the new table.");
          } finally {
            Variables.getReadLock().unlock();
          }
        }
        db.query("DELETE FROM " + OLD_TABLE_NAME + " WHERE value IS NULL");
        db.query("DELETE FROM old USING " + OLD_TABLE_NAME + " AS old, " + TABLE_NAME + " AS new WHERE old.name = new.name");
        final ResultSet r = db.query("SELECT * FROM " + OLD_TABLE_NAME + " LIMIT 1");
        try {
          if (r.next()) {// i.e. the old table is not empty
            Skript.error("Could not successfully convert & transfer all variables to the new table in the database '" + databaseName + "'. "
View Full Code Here

          } finally {
            Variables.getReadLock().unlock();
          }
        }
        db.query("DELETE FROM " + OLD_TABLE_NAME + " WHERE value IS NULL");
        db.query("DELETE FROM old USING " + OLD_TABLE_NAME + " AS old, " + TABLE_NAME + " AS new WHERE old.name = new.name");
        final ResultSet r = db.query("SELECT * FROM " + OLD_TABLE_NAME + " LIMIT 1");
        try {
          if (r.next()) {// i.e. the old table is not empty
            Skript.error("Could not successfully convert & transfer all variables to the new table in the database '" + databaseName + "'. "
                + "Variables that could not be transferred are left in the old table and Skript will reattempt to transfer them whenever it starts until the old table is empty or is manually deleted. "
View Full Code Here

            Variables.getReadLock().unlock();
          }
        }
        db.query("DELETE FROM " + OLD_TABLE_NAME + " WHERE value IS NULL");
        db.query("DELETE FROM old USING " + OLD_TABLE_NAME + " AS old, " + TABLE_NAME + " AS new WHERE old.name = new.name");
        final ResultSet r = db.query("SELECT * FROM " + OLD_TABLE_NAME + " LIMIT 1");
        try {
          if (r.next()) {// i.e. the old table is not empty
            Skript.error("Could not successfully convert & transfer all variables to the new table in the database '" + databaseName + "'. "
                + "Variables that could not be transferred are left in the old table and Skript will reattempt to transfer them whenever it starts until the old table is empty or is manually deleted. "
                + "Please note that variables recreated by scripts will count as converted and will be removed from the old table on the next restart.");
View Full Code Here

          } else {
            boolean error = false;
            try {
              disconnect(); // prevents SQLITE_LOCKED error
              connect();
              db.query("DROP TABLE " + OLD_TABLE_NAME);
            } catch (final SQLException e) {
              Skript.error("There was an error deleting the old variables table from the database '" + databaseName + "', please delete it yourself: " + e.getLocalizedMessage());
              error = true;
            }
            if (!error)
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.