Set<String> set = database.getTableNames(); String[] tablenames = set.toArray( new String[set.size()] ); EnterSelectionDialog dialog =
Set<String> settables = accessDatabase.getTableNames();
private void createIndexesUK() throws SQLException, IOException { for (String tn : dbIO.getTableNames()) { if (!this.unresolvedTables.contains(tn)) { this.loadTableIndexesUK(tn); conn.commit(); } } }
private void createFKs() throws SQLException, IOException { for (String tn : dbIO.getTableNames()) { if (!this.unresolvedTables.contains(tn)) { this.loadTableFKs(tn, false); conn.commit(); } } }
private void createIndexesNotUK() throws SQLException, IOException { for (String tn : dbIO.getTableNames()) { if (!this.unresolvedTables.contains(tn)) { this.loadTableIndexesNotUK(tn); conn.commit(); } } }
@Override public Collection<ITable> getTables() { ArrayList<ITable> ret = new ArrayList<ITable>(); try { for (String s : getDb().getTableNames()) { ret.add(new Table(s)); } } catch (Exception e) { ret.clear(); } return ret; }
/** * Copy all tables into new delimited text files <br> * Equivalent to: {@code exportFile(db, name, f, false, null, '"', * SimpleExportFilter.INSTANCE);} * * @param db * Database the table to export belongs to * @param dir * The directory where the new files will be created * @param ext * The file extension of the new files * * @see #exportFile(Database,String,File,boolean,String,char,ExportFilter) * @see Builder */ public static void exportAll(Database db, File dir, String ext) throws IOException { for (String tableName : db.getTableNames()) { exportFile(db, tableName, new File(dir, tableName + "." + ext), false, DEFAULT_DELIMITER, DEFAULT_QUOTE_CHAR, SimpleExportFilter.INSTANCE); } }
/** * Copy all tables into new delimited text files <br> * Equivalent to: {@code exportFile(db, name, f, false, null, '"', * SimpleExportFilter.INSTANCE);} * * @param db * Database the table to export belongs to * @param dir * The directory where the new files will be created * @param ext * The file extension of the new files * @param header * If <code>true</code> the first line contains the column names * * @see #exportFile(Database,String,File,boolean,String,char,ExportFilter) * @see Builder */ public static void exportAll(Database db, File dir, String ext, boolean header) throws IOException { for (String tableName : db.getTableNames()) { exportFile(db, tableName, new File(dir, tableName + "." + ext), header, DEFAULT_DELIMITER, DEFAULT_QUOTE_CHAR, SimpleExportFilter.INSTANCE); } }
char quote, ExportFilter filter) throws IOException { for (String tableName : db.getTableNames()) { exportFile(db, tableName, new File(dir, tableName + "." + ext), header, delim, quote, filter);
static void exportAll(File inputFile, boolean withHeader, File outputDir, String csvPrefix, boolean applyQuotesToAll, String nullText) throws IOException{ Database db = DatabaseBuilder.open(inputFile); try{ for(String tableName : db.getTableNames()){ String csvName = csvPrefix + tableName + ".csv"; File outputFile = new File(outputDir, csvName); Writer csv = new FileWriter(outputFile); try{ System.out.println(String.format("Exporting '%s' to %s", tableName, outputFile.toString())); int rows = export(db, tableName, csv, withHeader, applyQuotesToAll, nullText); System.out.println(String.format("%d rows exported", rows)); }finally{ try{ csv.flush(); csv.close(); }catch(IOException ex){} } } }finally{ db.close(); } }
public static final JackcessDenseObjectMatrix2D toFile(File file, Object... parameters) throws IOException { Database db = DatabaseBuilder.open(file); Set<String> tables = db.getTableNames(); String tablename = null; if (parameters.length != 0) { tablename = StringUtil.convert(parameters[0]); } if (tablename == null) { if (tables.size() == 1) { tablename = db.getTableNames().iterator().next(); } } db.close(); if (tablename == null) { throw new IllegalArgumentException( "please append the table name, i.e. one of these tables: " + tables); } return new JackcessDenseObjectMatrix2D(file, tablename); }
private void createAutoFKs() throws SQLException, IOException { for (String tn : dbIO.getTableNames()) { if (!this.unresolvedTables.contains(tn)) { try { this.loadTableFKs(tn, true); } catch (SQLException e) { UcanaccessTable t = new UcanaccessTable(dbIO.getTable(tn), tn); makeTableReadOnly(t, false); } conn.commit(); } } }
static void schema(File inputFile) throws IOException{ Database db = DatabaseBuilder.open(inputFile); try{ for(String tableName : db.getTableNames()){ Table table = db.getTable(tableName); System.out.println(String.format("CREATE TABLE %s (", tableName)); for(Column col : table.getColumns()){ System.out.println(String.format(" %s %s,", col.getName(), col.getType())); } System.out.println(")"); } }finally{ db.close(); } }
private void createTables() throws SQLException, IOException { metadata.createMetadata(); for (String tn : dbIO.getTableNames()) { UcanaccessTable t = null; Table t2 = null; try { t2 = dbIO.getTable(tn); t = new UcanaccessTable(t2, tn); } catch (Exception e) { Logger.logWarning(e.getMessage()); this.unresolvedTables.add(tn); } if (t2 != null && t != null && !tn.startsWith("~")) { createTable(t); this.loadingOrder.add(t.getName()); } } }
Set<String> tableNames = database.getTableNames(); buffer.append("Detect ").append(tableNames.size()).append(" tables."); for (String tableName : tableNames) {
protected Table getTable(String tableName, UcanaccessConnection conn) throws IOException { Table t = conn.getDbIO().getTable(tableName); if (t == null && tableName.startsWith(ESCAPE_PREFIX) && SQLConverter.isXescaped(tableName.substring(1))) { t = conn.getDbIO().getTable(tableName.substring(1)); if (t != null) { return new UcanaccessTable(t, tableName.substring(1)); } } if (t == null) { Database db = conn.getDbIO(); for (String cand : db.getTableNames()) { if (SQLConverter.preEscapingIdentifier(cand).equals(tableName) || SQLConverter.escapeIdentifier(cand).equals(tableName)) { t = new UcanaccessTable(db.getTable(cand), cand); break; } } } return new UcanaccessTable(t, tableName); }
@Override public void loadData(List<Tuple<String, File>> files, Importer importer) throws InvalidFileException, IOException { Database database = DatabaseBuilder.open(files.get(0).getRight()); for (String tableName : database.getTableNames()) { importer.startCollection(tableName); Table table = database.getTable(tableName); List<? extends Column> columns = table.getColumns(); for (int i = 0; i < columns.size(); i++) { importer.registerPropertyName(i, columns.get(i).getName()); } for (Row row : table) { importer.startEntity(); for (int colNum = 0 ; colNum < columns.size(); colNum++) { Object cellValue = row.get(columns.get(colNum).getName()); if (cellValue == null) { cellValue = ""; } importer.setValue(colNum, "" + cellValue); } importer.finishEntity(); } importer.finishCollection(); } } }
private void readTables() throws IOException, SQLException { for (String tableName : jackcessDatabase.getTableNames()) { Table table = new Table(); table.setName(tableName); table.addAllColumns(readTableColumns(tableName)); readTableData(table); if (table.hasPrimaryKey() && table.getPrimaryColumn().getDataType() instanceof NumberDataType) table.setNextValue(findMaxPrimaryKeyValue(table) + 1); database.addTable(table); } }
private void buildForeignKeys() throws IOException { for (String tableName : jackcessDatabase.getTableNames()) { List<com.healthmarketscience.jackcess.Column> originalColumns = getColumns(tableName); for (com.healthmarketscience.jackcess.Column column : originalColumns) {