Examples of Database


Examples of de.kilobyte22.app.kibibyte.Database

                //return tmp;
            }
        }
    }
    public void setPermissions(String nick, HashMap<String, Boolean> perms) {
        Database database = bot.database;
        String tmpperms = "";
        for(String key : perms.keySet()) {
            if (!tmpperms.equals("")) tmpperms += ";";
            if (perms.get(key) != null) tmpperms += key + "=" + (perms.get(key) ? "true" : "false");
        }
        logger.log(tmpperms);
        try {
            if (bot.useYaml) {
                HashMap<String, String> perms_ = bot.yamlEngine.load(new File("permissions.yaml"));
                perms_.put(nick, tmpperms);
                bot.yamlEngine.writeYaml(new File("permissions.yaml"), perms_);
            } else {
                PreparedStatement s = database.prepareStatement("SELECT * FROM permissions WHERE server = ? AND nickserv = ?");
                s.setString(1, bot.getServer());
                s.setString(2, nick);
                try {
                    //s.executeQuery().next();
                    s = database.prepareStatement("UPDATE permissions SET permissions=? WHERE server = ? AND nickserv = ?");
                    s.setString(1, tmpperms);
                    s.setString(2, bot.getServer());
                    s.setString(3, nick);
                    if (!s.execute())
                        throw new Exception("");
                    logger.log(s.toString());
                } catch (Exception ex) {
                    //logger.log(ex);
                    //s.executeQuery().next();
                    s = database.prepareStatement("INSERT INTO permissions (server, nickserv, permissions) VALUES (?, ?, ?)");
                    s.setString(1, bot.getServer());
                    s.setString(2, nick);
                    s.setString(3, tmpperms);
                    s.execute();
                }
View Full Code Here

Examples of de.lmu.ifi.dbs.elki.database.Database

        filterlist.add(filter);
      }
    }
    params.addParameter(FileBasedDatabaseConnection.FILTERS_ID, filterlist);
    params.addParameter(FixedDBIDsFilter.IDSTART_ID, 1);
    Database db = ClassGenericsUtil.parameterizeOrAbort(StaticArrayDatabase.class, params);

    testParameterizationOk(params);

    db.initialize();
    Relation<?> rel = db.getRelation(TypeUtil.ANY);
    org.junit.Assert.assertEquals("Database size does not match.", expectedSize, rel.size());
    return db;
  }
View Full Code Here

Examples of edu.mit.simile.backstage.model.data.Database

      }
     
    @Override
    protected Object internalRun() {
            _logger.debug("> internalRun");
          Database database = _context.getDatabase();
         
          DefaultScriptableObject result = new DefaultScriptableObject();
          ScriptableArrayBuilder itemIDs = new ScriptableArrayBuilder();
          ScriptableArrayBuilder lenses = new ScriptableArrayBuilder();
         
          int count = 0;
         
          try {
              SailRepositoryConnection connection = (SailRepositoryConnection)
                  database.getRepository().getConnection();
             
              try {
                  TupleQuery query = _builder.makeTupleQuery(_itemVar, connection);
                  TupleQueryResult queryResult = query.evaluate();
                  try {
                      while (queryResult.hasNext()) {
                          BindingSet bindingSet = queryResult.next();
                          Value v = bindingSet.getValue(_itemVar.getName());
                          if (v instanceof URI) {
                              if (count < 20) {
                                String itemID = database.getItemId((URI) v);
                                  itemIDs.add(itemID);
                                  lenses.add(_context.generateLens(itemID));
                              }
                              count++;
                          }
View Full Code Here

Examples of fi.evident.dalesbred.Database

    @Test
    public void testCreation() {
        Injector injector = Guice.createInjector(new DriverManagerDatabaseModule(), TestDatabaseProvider.inMemoryDatabasePropertiesModule());

        Database db = injector.getInstance(Database.class);

        Employee employee = db.findUnique(Employee.class, "values (42, 'Fred Foo')");
        assertThat(employee.id, is(42));
        assertThat(employee.name, is("Fred Foo"));
        assertThat(employee.db, is(db));
    }
View Full Code Here

Examples of fr.esrf.TangoApi.Database

   
    protected String getDeviceAlias()
    {
        String alias = "";
        if(!getDeviceName().isEmpty()){
            Database db = TangoDeviceHelper.getDatabase();
            if (db != null) {
                try {
                    alias = db.get_alias_from_device(getDeviceName());
                } catch (DevFailed e) {
                    System.err.println("Error during device alias reading");
                    alias = "";
                }
            }
View Full Code Here

Examples of groundTruthModule.datastructure.DataBase

* @param ship the ship
* @param evidenceList the evidence list
*/
private void addEvidence(ShipEntity ship, List<EvidenceInfo> evidenceList) {

    DataBase db = DataBase.getInstance();

    String shipName;
    String ship2Name;
    String personName;
    String organizationName;
    EvidenceInfo evidence;
    ArgumentInfo argument;

    // TODO - Make sure to use a unique id later on
    shipName = "ship" + db.getShips().indexOf(ship);
   
    // Ship characteristics
    if (ship.getShipType() != null) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasTypeOfShip");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      if (ship.getShipType() == ShipType.FISHING) {
        evidence.setState("Fishing");
      } else {
        evidence.setState("Merchant");
      }
      evidenceList.add(evidence);
    }
   
    // Evidence that support the hypothesis hasEvasiveBehavior(ship)
    if (!ship.hasResponsiveAIS()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasResponsiveAIS");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("false");
      evidenceList.add(evidence);
    }
    if (!ship.hasResponsiveRadio()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasResponsiveRadio");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("false");
      evidenceList.add(evidence);
    }
   
    // Evidence (report) that supports the hypothesis hasUnusualRoute(ship)
    if (ship.isOnUnusualRoute()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasUnusualRouteReport");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("true");
      evidenceList.add(evidence);
    }
   
    // Load all ships that possibly met
    // Also evidence (report) that supports the hypothesis hasUnusualRoute(ship)
    if (ship.getPossibleMeeting().size() > 0) {
      for (ShipEntity shipMeeting : ship.getPossibleMeeting()) {
        evidence = new EvidenceInfo();
        evidence.setResidentNode("areMeetingReport");
        ship2Name = "ship" + db.getShips().indexOf(shipMeeting);
        argument = new ArgumentInfo();
        argument.setType("Ship");
        argument.setName(shipName);
        evidence.getArguments().add(argument);
        argument = new ArgumentInfo();
        argument.setType("Ship");
        argument.setName(ship2Name);
        evidence.getArguments().add(argument);
        evidence.setState("true");
        evidenceList.add(evidence);
      }
    }
   
    // Evidence that support the hypothesis hasErraticBehavior(ship)
    if (ship.isCrewVisible()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("isCrewVisible");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("true");
      evidenceList.add(evidence);
    }
   
    // Evidence that support the hypothesis hasAggressiveBehavior(ship)
    if (ship.hasWeaponVisible()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasWeaponVisible");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("true");
      evidenceList.add(evidence);
    }
    if (ship.isJettisoningCargo()) {
      evidence = new EvidenceInfo();
      evidence.setResidentNode("isJettisoningCargo");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      evidence.setState("true");
      evidenceList.add(evidence);
    }
   
   
    // Load all crew members
    for (PersonEntity person : ship.getCrew()) {

      // TODO - Make sure to use a unique id later on
      personName = "person" + db.getPeople().indexOf(person);
     
      // Adding finding stating that this person is a crew member of this ship
      evidence = new EvidenceInfo();
      evidence.setResidentNode("hasCrewMember");
      argument = new ArgumentInfo();
      argument.setType("Ship");
      argument.setName(shipName);
      evidence.getArguments().add(argument);
      argument = new ArgumentInfo();
      argument.setType("Person");
      argument.setName(personName);
      evidence.getArguments().add(argument);
      evidence.setState("true");
      evidenceList.add(evidence);

      // Add information about the terrorist organizations associated to this crew member
      if (person.isPartOfTerroristOrganisation()) {
        for (OrganizationEntity organization : person
            .getRelatedOrganizations()) {
          if (organization.isTerroristOrganisation()) {
            // TODO - Make sure to use a unique id later on
            organizationName = "organization"
                + db.getOrganizations().indexOf(organization);
           
            // Add this crew member as member of this organization
            evidence = new EvidenceInfo();
            evidence.setResidentNode("isMemberOfOrganization");
            argument = new ArgumentInfo();
View Full Code Here

Examples of jimm.datavision.source.sql.Database

* is reset.
*
* @param conn a database connection
*/
public void setDatabaseConnection(Connection conn) throws SQLException {
    dataSource = new Database(conn, this);
    databasePassword = ""// So user won't be asked for password
}
View Full Code Here

Examples of ke.go.moh.oec.oecsm.data.Database

        statement.close();
        return table;
    }

    private Database findDatabase(int id) throws SQLException, InaccessibleConfigurationFileException, DriverNotFoundException {
        Database db = null;
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("SELECT `database`.`ID`, `database`.`NAME` FROM `database` WHERE `database`.`ID` = " + id + "");
        if (rs.next()) {
            db = new Database(rs.getInt("ID"), rs.getString("NAME"));
        }
        rs.close();
        statement.close();
        return db;
    }
View Full Code Here

Examples of labsis.DataBase

public class DaoProduto {

  private Connection conn;

  public DaoProduto() throws SQLException {
    DataBase db = DataBase.getDb();
    conn = db.getConnection();
  }
View Full Code Here

Examples of lib.PatPeter.SQLibrary.Database

    if (monitor_changes == null || monitor_interval == null)
      return false;
    monitor = monitor_changes;
    this.monitor_interval = monitor_interval.getMilliSeconds();
   
    final Database db;
    try {
      final Object o = type.initialise(this, n);
      if (o == null)
        return false;
      this.db = db = (Database) o;
    } catch (final RuntimeException e) {
      if (e instanceof DatabaseException) {// not in a catch clause to not produce a ClassNotFoundException when this class is loaded and SQLibrary is not present
        Skript.error(e.getMessage());
        return false;
      }
      throw e;
    }
   
    SkriptLogger.setNode(null);
   
    if (!db.open()) {
      Skript.error("Cannot connect to the database '" + databaseName + "'!");
      return false;
    }
   
    // periodically executes queries to keep the collection alive
    final Task keepAlive = new Task(Skript.getInstance(), 20, 20, true) {
      @Override
      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);
   
    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;
      }
     
      if (!prepareQueries()) {
        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();
        }
      }
     
      // new
      final ResultSet r2 = db.query("SELECT " + SELECT_ORDER + " FROM " + TABLE_NAME);
      assert r2 != null;
      try {
        loadVariables(r2);
      } finally {
        r2.close();
      }
     
      // store old variables in new table and delete the old table
      if (hasOldTable) {
        if (!hadNewTable) {
          Skript.info("[2.1] Updating the database '" + databaseName + "' to the new format...");
          try {
            Variables.getReadLock().lock();
            for (final Entry<String, Object> v : Variables.getVariablesHashMap().entrySet()) {
              if (accept(v.getKey())) {// only one database was possible, so only checking this database is correct
                @SuppressWarnings("null")
                final SerializedVariable var = Variables.serialize(v.getKey(), v.getValue());
                final SerializedVariable.Value d = var.value;
                save(var.name, d == null ? null : d.type, d == null ? null : d.data);
              }
            }
            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 + "'. "
                + "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.");
          } 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.