Ejemplo n.º 1
0
 /**
  * Fetches the next row from the table, ignoring potential parsing exceptions.
  *
  * @param table Table to fetch the next available row from.
  * @return <code>true</code> if there are further rows to fetch. <code>false</code> if there are
  *     no further rows to fetch or an exception is thrown while parsing the row.
  */
 private boolean fetchRow(MdbTableDef table) {
   try {
     return Data.mdb_fetch_row(table);
   } catch (Exception e) {
     return false;
   }
 }
Ejemplo n.º 2
0
  /* @see MDBService#parseDatabase() */
  public Vector<Vector<String[]>> parseDatabase() throws IOException {
    List catalog = mdb.catalog;

    Vector<Vector<String[]>> rtn = new Vector<Vector<String[]>>();

    int previousColumnCount = 0;

    for (Object entry : catalog) {
      int type = ((MdbCatalogEntry) entry).object_type;
      String name = ((MdbCatalogEntry) entry).object_name;

      if (type == Constants.MDB_TABLE && !name.startsWith("MSys")) {
        Vector<String[]> tableData = new Vector<String[]>();
        MdbTableDef table = Table.mdb_read_table((MdbCatalogEntry) entry);
        Table.mdb_read_columns(table);

        int numCols = table.num_cols;
        for (int i = 0; i < numCols; i++) {
          Holder h = new Holder();
          Data.mdb_bind_column(table, i + 1, h);
          boundValues.add(h);
        }

        String[] columnNames = new String[numCols + 1];
        columnNames[0] = name;
        for (int i = 0; i < numCols; i++) {
          columnNames[i + 1] = ((MdbColumn) table.columns.get(i)).name;
        }
        tableData.add(columnNames);

        while (fetchRow(table)) {
          String[] row = new String[numCols];
          for (int i = 0; i < numCols; i++) {
            Holder h = boundValues.get(i + previousColumnCount);
            row[i] = h.s;
          }
          tableData.add(row);
        }

        previousColumnCount += numCols;
        rtn.add(tableData);
      }
    }
    return rtn;
  }