예제 #1
0
파일: JdbcDBI.java 프로젝트: mjlim/db
  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;
  }
예제 #2
0
파일: JdbcDBI.java 프로젝트: mjlim/db
  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;
  }