Пример #1
0
  private void insertDb(SqlJetDb sqlJetDb, List<?> list, String table) throws Exception {
    try {
      sqlJetDb.beginTransaction(SqlJetTransactionMode.WRITE);
      ISqlJetTable iSqlJetTable = sqlJetDb.getTable(table);
      for (int i = 0; i < list.size(); i++)
        iSqlJetTable.insertByFieldNames(this.retrieveObjectMap(list.get(i)));

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      sqlJetDb.commit();
    }
  }
Пример #2
0
  private File createNewRawDbFile(List<String> tableList) throws Exception {
    File tempDbFile = File.createTempFile("temp", System.currentTimeMillis() + ".sql");

    SqlJetDb sqlJetDb = SqlJetDb.open(tempDbFile, true);
    sqlJetDb.getOptions().setAutovacuum(true);
    sqlJetDb.beginTransaction(SqlJetTransactionMode.WRITE);
    try {
      sqlJetDb.getOptions().setUserVersion(1);
      for (int i = 0; i < tableList.size(); i++) this.createTableNIndex(sqlJetDb, tableList.get(i));
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      sqlJetDb.commit();
    }

    return tempDbFile;
  }