private void loadTableData( final File dbFile, final TableViewer guiTableViewer, final String dbTableName) { SqlJetDb db = null; try { db = SqlJetDb.open(dbFile, true); final ISqlJetTable dbTable = db.getTable(dbTableName); final ArrayList<DataRow> data = new ArrayList<DataRow>(); final ISqlJetTableDef tableDef = dbTable.getDefinition(); final List<String> names = new ArrayList<String>(); for (final ISqlJetColumnDef column : tableDef.getColumns()) { names.add(column.getName()); } final String[] namesArray = names.toArray(new String[names.size()]); final Table guiTable = guiTableViewer.getTable(); createGuiTableColumns(guiTable, namesArray); dbTable .getDataBase() .runReadTransaction( new ISqlJetTransaction() { @Override public Object run(final SqlJetDb db) throws SqlJetException { final ISqlJetCursor cursor = dbTable.open(); try { int count = 0; while (!cursor.eof()) { data.add(DataRow.read(cursor, count, namesArray)); cursor.next(); count++; } } finally { cursor.close(); } return null; } }); // Populate data and refresh table viewer guiTableViewer.setInput(data); guiTableViewer.refresh(); } catch (final Exception e) { e.printStackTrace(); } finally { if (db != null) { try { db.close(); } catch (final SqlJetException e) { e.printStackTrace(); } } } }
private ISqlJetSchema getSqlJetSchema(final File dbFile) { SqlJetDb db = null; try { db = SqlJetDb.open(dbFile, true); return db.getSchema(); } catch (final SqlJetException e) { e.printStackTrace(); } finally { if (db != null) { try { db.close(); } catch (final SqlJetException e) { e.printStackTrace(); } } } return null; }