Exemple #1
0
 public void updateRecord(VersionManifest match, VersionManifest update) throws DBIException {
   try {
     this.open();
     this.updateRecordFromMapQuery(match.createMap(), update.createMap());
     this.close();
   } catch (SQLException e) {
     throw new DBIException(
         e); // create a generic DBIException from this SQLException and throw it
   }
 }
Exemple #2
0
  private List<VersionManifest> findFromMapQuery(Map<String, String> map) throws SQLException {
    if (conn.isClosed()) throw new SQLException("Connection is closed, cannot find record");

    String where = "";
    String col;
    String[] values = new String[map.size()];

    Iterator<String> colIter = map.keySet().iterator();

    for (int i = 0; i < map.size(); i++) {
      col = colIter.next();
      values[i] = map.get(col);

      where += col + " = ?";
      if (i < map.size() - 1) where += " AND ";
    }

    String query = "SELECT * FROM " + config.get(CONFIG_TABLENAME) + " WHERE " + where;

    PreparedStatement stmt = this.conn.prepareStatement(query);

    for (int i = 0; i < values.length; i++) {
      stmt.setString(i + 1, values[i]);
    }

    ResultSet rs = stmt.executeQuery();

    List<VersionManifest> mpvList = VersionManifest.fromResultSet(rs);

    rs.close();

    return mpvList;
  }
Exemple #3
0
 public void addRecord(VersionManifest vm) throws DBIException {
   try {
     this.open();
     this.addRecordFromMapQuery(vm.createMap());
     this.close();
   } catch (SQLException e) {
     throw new DBIException(
         e); // create a generic DBIException from this SQLException and throw it
   }
 }
Exemple #4
0
 public List<VersionManifest> find(VersionManifest vm) throws DBIException {
   List<VersionManifest> results;
   try {
     this.open();
     results = this.findFromMapQuery(vm.createMap());
     this.close();
   } catch (SQLException e) {
     throw new DBIException(
         e); // create a generic DBIException from this SQLException and throw it
   }
   return results;
 }
Exemple #5
0
  private List<VersionManifest> findAllQuery() throws SQLException {
    if (conn.isClosed()) throw new SQLException("Connection is closed, cannot find records");

    String query = "SELECT * FROM " + config.get(CONFIG_TABLENAME);

    PreparedStatement stmt = this.conn.prepareStatement(query);

    ResultSet rs = stmt.executeQuery();

    List<VersionManifest> mpvList = VersionManifest.fromResultSet(rs);

    rs.close();

    return mpvList;
  }