Table invoices = db_opened.getTable("Invoices"); Table invoices_lignes = db_opened.getTable("InvoicesLignes"); Cursor cursor = CursorBuilder.createCursor(invoices_lignes.getIndex("Code")); for (Row row : invoices) { long start = System.currentTimeMillis( ); System.out.println(String.format("Invoice : '%s'", start)); for (Row crow : cursor.newIterable().addMatchPattern("Code", row.get("Code"))) { System.out.println(String.format("Loop : '%s'", System.currentTimeMillis( ))); } long end = System.currentTimeMillis( ); System.out.println(String.format("End loop : '%s'", System.currentTimeMillis( ))); long diff = end - start; System.out.println(String.format("Loop elapsed time : '%s' ms", diff )); }
Table table = DatabaseBuilder.open(new File("my.mdb")).getTable("MyTable"); Cursor cursor = CursorBuilder.createCursor(table); for (Row row : cursor.newIterable().addMatchPattern("a", "foo")) { System.out.println(String.format( "a='%s', SomeFieldName='%s'.", row.get("a"), row.get("SomeFieldName"))); }
Database db = DatabaseBuilder.open(new File( "C:/Users/Gord/Desktop/Database1.accdb")); Table tbl = db.getTable("MyTable"); Cursor crsr = new CursorBuilder(tbl) .setIndex(tbl.getIndex("alias")) .setStartEntry("B0") .setEndEntry("B0") .toCursor(); List<Row> rowList = new ArrayList<Row>(); for (Row r : crsr.newIterable()) { rowList.add(r); }
Map<String, String> testData = new Hashtable<String, String>(); String dbFile = "C:/Users/Public/test/DB.mdb"; try (Database db = DatabaseBuilder.open(new File(dbFile))) { Table table = db.getTable("db_data"); Cursor cursor = CursorBuilder.createCursor(table); int testCaseId = 1; for (Row row : cursor.newIterable().addMatchPattern("TestCaseId", testCaseId)) { testData.put(row.get("Key").toString(), row.get("Data").toString()); } Iterator<Map.Entry<String, String>> it = testData.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> entry = it.next(); System.out.println(String.format( "Key: %s, Data: %s", entry.getKey(), entry.getValue())); } } catch (Exception e) { e.printStackTrace(System.out); }
String dbFile = "C:/Users/Public/test/DB.mdb"; try (Database db = DatabaseBuilder.open(new File(dbFile))) { Table table = db.getTable("Table1"); Cursor cursor = CursorBuilder.createCursor(table); int testNum = 1; for (Row row : cursor.newIterable().addMatchPattern("testnum", testNum)) { row.put("active", true); table.updateRow(row); } } catch (Exception e) { e.printStackTrace(System.out); }
public void getTableNames(Set<String> tableNames, boolean normalTables, boolean systemTables, boolean linkedTables) throws IOException { for(Row row : getTableNamesCursor().newIterable().setColumnNames( SYSTEM_CATALOG_COLUMNS)) { String tableName = row.getString(CAT_COL_NAME); int flags = row.getInt(CAT_COL_FLAGS); Short type = row.getShort(CAT_COL_TYPE); int parentId = row.getInt(CAT_COL_PARENT_ID); if(parentId != _tableParentId) { continue; } if(TYPE_TABLE.equals(type)) { if(!isSystemObject(flags)) { if(normalTables) { tableNames.add(tableName); } } else if(systemTables) { tableNames.add(tableName); } } else if(TYPE_LINKED_TABLE.equals(type) && linkedTables) { tableNames.add(tableName); } } }
public boolean isLinkedTable(Table table) throws IOException { for(Row row : getTableNamesCursor().newIterable().setColumnNames( SYSTEM_CATALOG_TABLE_DETAIL_COLUMNS)) { Short type = row.getShort(CAT_COL_TYPE); String linkedDbName = row.getString(CAT_COL_DATABASE); String linkedTableName = row.getString(CAT_COL_FOREIGN_NAME); if(TYPE_LINKED_TABLE.equals(type) && matchesLinkedTable(table, linkedTableName, linkedDbName)) { return true; } } return false; }
Object[] entryValues = new Object[_secondaryCols.size()]; for(Row row : _secondaryTable.newCursor().toCursor() .newIterable().addColumns(_secondaryCols)) {
@Override public TableInfo lookupTable(String tableName) throws IOException { for(Row row : _systemCatalogCursor.newIterable().setColumnNames( SYSTEM_CATALOG_TABLE_DETAIL_COLUMNS)) { Short type = row.getShort(CAT_COL_TYPE); if(!isTableType(type)) { continue; } int parentId = row.getInt(CAT_COL_PARENT_ID); if(parentId != _tableParentId) { continue; } String realName = row.getString(CAT_COL_NAME); if(!tableName.equalsIgnoreCase(realName)) { continue; } Integer pageNumber = row.getInt(CAT_COL_ID); int flags = row.getInt(CAT_COL_FLAGS); String linkedDbName = row.getString(CAT_COL_DATABASE); String linkedTableName = row.getString(CAT_COL_FOREIGN_NAME); return createTableInfo(realName, pageNumber, flags, type, linkedDbName, linkedTableName); } return null; }