本文整理汇总了Java中com.healthmarketscience.jackcess.Database.getTableNames方法的典型用法代码示例。如果您正苦于以下问题:Java Database.getTableNames方法的具体用法?Java Database.getTableNames怎么用?Java Database.getTableNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Database
的用法示例。
在下文中一共展示了Database.getTableNames方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
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);
}
示例2: export
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
* Export the Access database to the given SQLite database. The referenced
* SQLite database should be empty.
*
* @param mdbFile The MS Access file.
* @param sqliteFile The SQLite file.
* @throws SQLException
* @throws SqlJetException
*/
public static void export(File mdbFile, File sqliteFile) throws Exception {
Database mdb = DatabaseBuilder.open(mdbFile);
SqlJetDb sqlite = SqlJetDb.open(sqliteFile, true);
sqlite.getOptions().setAutovacuum(true);
sqlite.beginTransaction(SqlJetTransactionMode.WRITE);
// Create the tables
MDB2SQLite.createTables(mdb, sqlite);
// Populate the tables
for (String tableName : mdb.getTableNames()) {
MDB2SQLite.populateTable(sqlite, mdb.getTable(tableName));
}
}
示例3: createTables
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
* Iterate over the MDB database and create SQLite tables for every table
* defined in the MS Access database.
*
* @param jdbc The SQLite database JDBC connection
*/
@SuppressWarnings("unchecked")
private static void createTables(Database mdb, SqlJetDb sqlite) throws Exception {
for (String tableName : mdb.getTableNames()) {
Table table = mdb.getTable(tableName);
sqlite.beginTransaction(SqlJetTransactionMode.WRITE);
try {
sqlite.createTable(MDB2SQLite.createTableStatement(table));
for (Index index : (List<Index>) table.getIndexes()) {
sqlite.createIndex(MDB2SQLite.createIndexStatement(index));
}
} finally {
sqlite.commit();
}
}
}
示例4: getTable
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
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){
Database db=conn.getDbIO();
for (String cand:db.getTableNames()){
if(SQLConverter.escapeIdentifier(cand).equals(tableName)){
return db .getTable(cand);
}
}
}
return t;
}
示例5: loadData
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
@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();
}
}
示例6: parseSchema
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
* Interpret the schema and create postgres structures
*
* @param databaseFile
* @param commit
* @param serverName
* @param databaseName
* @return a map of TableImportResult instances with table creation results
* @throws IOException
*/
private Map<String, TableImportResult> parseSchema(File databaseFile,
boolean commit, String serverName, String databaseName)
throws IOException {
Database database = DatabaseBuilder.open(databaseFile);
Map<String, TableImportResult> results = new HashMap<String, TableImportResult>();
//
// Tables
//
Set<String> tablesName = database.getTableNames();
Iterator<String> tables = tablesName.iterator();
while (tables.hasNext()) {
Table table = database.getTable(tables.next());
TableImportResult result = new TableImportResult();
if (!excludeTable(table.getName())) {
if (!createTableStructure(table, commit, serverName,
databaseName)) {
log.error("Unable to create table structure");
result.setTableCreateResult(TableImportResult.FAILED);
} else {
result.setTableCreateResult(TableImportResult.SUCCESSFUL);
}
}
results.put(getNormalisedTableName(table.getName()), result);
}
//
// Constraints
//
Map<String, TableImportResult> constraintResults = createForeignKeys(
serverName, databaseName, database, commit);
//
// Merge results
//
for (String key : results.keySet()) {
results.get(key).merge(constraintResults.get(key));
}
return results;
}
示例7: exportAll
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
* 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);
}
}