本文整理汇总了Java中com.healthmarketscience.jackcess.Database.getTable方法的典型用法代码示例。如果您正苦于以下问题:Java Database.getTable方法的具体用法?Java Database.getTable怎么用?Java Database.getTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Database
的用法示例。
在下文中一共展示了Database.getTable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createUniqueTable
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
* Returns a new table with a unique name and the given table definition.
*/
private static Table createUniqueTable(Database db, String name,
List<ColumnBuilder> columns,
ResultSetMetaData md,
ImportFilter filter)
throws IOException, SQLException
{
// otherwise, find unique name and create new table
String baseName = name;
int counter = 2;
while(db.getTable(name) != null) {
name = baseName + (counter++);
}
return new TableBuilder(name)
.addColumns(filter.filterColumns(columns, md))
.toTable(db);
}
示例2: testImportFromFileWithOnlyHeaders
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testImportFromFileWithOnlyHeaders() throws Exception
{
for (final FileFormat fileFormat : JetFormatTest.SUPPORTED_FILEFORMATS) {
Database db = create(fileFormat);
String tableName = new ImportUtil.Builder(db, "test")
.setDelimiter("\\t")
.importFile(new File("src/test/data/sample-input-only-headers.tab"));
Table t = db.getTable(tableName);
List<String> colNames = new ArrayList<String>();
for(Column c : t.getColumns()) {
colNames.add(c.getName());
}
assertEquals(Arrays.asList(
"RESULT_PHYS_ID", "FIRST", "MIDDLE", "LAST", "OUTLIER",
"RANK", "CLAIM_COUNT", "PROCEDURE_COUNT",
"WEIGHTED_CLAIM_COUNT", "WEIGHTED_PROCEDURE_COUNT"),
colNames);
db.close();
}
}
示例3: testReadCalcFields
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testReadCalcFields() throws Exception {
for(TestDB testDB : TestDB.getSupportedForBasename(Basename.CALC_FIELD)) {
Database db = open(testDB);
Table t = db.getTable("Table1");
List<String> rows = new ArrayList<String>();
for(Row r : t) {
rows.add(r.entrySet().toString());
}
List<String> expectedRows = Arrays.asList(
"[ID=1, FirstName=Bruce, LastName=Wayne, LastFirst=Wayne, Bruce, City=Gotham, LastFirstLen=12, Salary=1000000.0000, MonthlySalary=83333.3333, IsRich=true, AllNames=Wayne, Bruce=Wayne, Bruce, WeeklySalary=19230.7692307692, SalaryTest=1000000.0000, BoolTest=true, Popularity=50.325000, DecimalTest=50.325000, FloatTest=2583.2092, BigNumTest=56505085819.424791296572280180]",
"[ID=2, FirstName=Bart, LastName=Simpson, LastFirst=Simpson, Bart, City=Springfield, LastFirstLen=13, Salary=-1.0000, MonthlySalary=-0.0833, IsRich=false, AllNames=Simpson, Bart=Simpson, Bart, WeeklySalary=-0.0192307692307692, SalaryTest=-1.0000, BoolTest=true, Popularity=-36.222200, DecimalTest=-36.222200, FloatTest=0.0035889593, BigNumTest=-0.0784734499180612994241100748]",
"[ID=3, FirstName=John, LastName=Doe, LastFirst=Doe, John, City=Nowhere, LastFirstLen=9, Salary=0.0000, MonthlySalary=0.0000, IsRich=false, AllNames=Doe, John=Doe, John, WeeklySalary=0, SalaryTest=0.0000, BoolTest=true, Popularity=0.012300, DecimalTest=0.012300, FloatTest=0.0, BigNumTest=0E-8]",
"[ID=4, FirstName=Test, LastName=User, LastFirst=User, Test, City=Hockessin, LastFirstLen=10, Salary=100.0000, MonthlySalary=8.3333, IsRich=false, AllNames=User, Test=User, Test, WeeklySalary=1.92307692307692, SalaryTest=100.0000, BoolTest=true, Popularity=102030405060.654321, DecimalTest=102030405060.654321, FloatTest=1.27413E-10, BigNumTest=2.787019289824216980830E-7]");
assertEquals(expectedRows, rows);
db.close();
}
}
示例4: x_testReadAllCodesMdb
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void x_testReadAllCodesMdb() throws Exception
{
// Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes.mdb"));
// Database db = openCopy(new File("/data2/jackcess_test/testAllIndexCodes_orig.mdb"));
// Database db = openCopy(new File("/data2/jackcess_test/testSomeMoreCodes.mdb"));
Database db = openCopy(Database.FileFormat.V2000, new File("/data2/jackcess_test/testStillMoreCodes.mdb"));
Table t = db.getTable("Table5");
Index ind = t.getIndexes().iterator().next();
((IndexImpl)ind).initialize();
System.out.println("Ind " + ind);
Cursor cursor = CursorBuilder.createCursor(ind);
while(cursor.moveToNextRow()) {
System.out.println("=======");
String entryStr =
entryToString(cursor.getSavepoint().getCurrentPosition());
System.out.println("Entry Bytes: " + entryStr);
System.out.println("Value: " + cursor.getCurrentRow() + "; " +
toUnicodeStr(cursor.getCurrentRow().get("data")));
}
db.close();
}
示例5: x_testReadIsoMdb
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void x_testReadIsoMdb() throws Exception
{
// Database db = open(new File("/tmp/test_ind.mdb"));
// Database db = open(new File("/tmp/test_ind2.mdb"));
Database db = open(Database.FileFormat.V2000, new File("/tmp/test_ind3.mdb"));
// Database db = open(new File("/tmp/test_ind4.mdb"));
Table t = db.getTable("Table1");
Index index = t.getIndex("B");
((IndexImpl)index).initialize();
System.out.println("Ind " + index);
Cursor cursor = CursorBuilder.createCursor(index);
while(cursor.moveToNextRow()) {
System.out.println("=======");
System.out.println("Savepoint: " + cursor.getSavepoint());
System.out.println("Value: " + cursor.getCurrentRow());
}
db.close();
}
示例6: testReadLongValue
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testReadLongValue() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.TEST2, true)) {
Database db = openMem(testDB);
Table table = db.getTable("MSP_PROJECTS");
Row row = table.getNextRow();
assertEquals("Jon Iles this is a a vawesrasoih aksdkl fas dlkjflkasjd flkjaslkdjflkajlksj dfl lkasjdf lkjaskldfj lkas dlk lkjsjdfkl; aslkdf lkasjkldjf lka skldf lka sdkjfl;kasjd falksjdfljaslkdjf laskjdfk jalskjd flkj aslkdjflkjkjasljdflkjas jf;lkasjd fjkas dasdf asd fasdf asdf asdmhf lksaiyudfoi jasodfj902384jsdf9 aw90se fisajldkfj lkasj dlkfslkd jflksjadf as", row.get("PROJ_PROP_AUTHOR"));
assertEquals("T", row.get("PROJ_PROP_COMPANY"));
assertEquals("Standard", row.get("PROJ_INFO_CAL_NAME"));
assertEquals("Project1", row.get("PROJ_PROP_TITLE"));
byte[] foundBinaryData = row.getBytes("RESERVED_BINARY_DATA");
byte[] expectedBinaryData =
toByteArray(new File("src/test/data/test2BinData.dat"));
assertTrue(Arrays.equals(expectedBinaryData, foundBinaryData));
db.close();
}
}
示例7: testLongValueAsMiddleColumn
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testLongValueAsMiddleColumn() throws Exception
{
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
Database db = createMem(fileFormat);
Table newTable = new TableBuilder("NewTable")
.addColumn(new ColumnBuilder("a").setSQLType(Types.INTEGER))
.addColumn(new ColumnBuilder("b").setSQLType(Types.LONGVARCHAR))
.addColumn(new ColumnBuilder("c").setSQLType(Types.VARCHAR))
.toTable(db);
String lval = createString(2000); // "--2000 chars long text--";
String tval = createString(40); // "--40chars long text--";
newTable.addRow(new Integer(1), lval, tval);
newTable = db.getTable("NewTable");
Map<String, Object> readRow = newTable.getNextRow();
assertEquals(new Integer(1), readRow.get("a"));
assertEquals(lval, readRow.get("b"));
assertEquals(tval, readRow.get("c"));
db.close();
}
}
示例8: doTestWriteAndRead
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private static void doTestWriteAndRead(Database db) throws Exception {
createTestTable(db);
Object[] row = createTestRow();
row[3] = null;
Table table = db.getTable("Test");
int count = 1000;
((DatabaseImpl)db).getPageChannel().startWrite();
try {
for (int i = 0; i < count; i++) {
table.addRow(row);
}
} finally {
((DatabaseImpl)db).getPageChannel().finishWrite();
}
for (int i = 0; i < count; i++) {
Map<String, Object> readRow = table.getNextRow();
assertEquals(row[0], readRow.get("A"));
assertEquals(row[1], readRow.get("B"));
assertEquals(row[2], readRow.get("C"));
assertEquals(row[3], readRow.get("D"));
assertEquals(row[4], readRow.get("E"));
assertEquals(row[5], readRow.get("F"));
assertEquals(row[6], readRow.get("G"));
assertEquals(row[7], readRow.get("H"));
}
}
示例9: testNoEnforceForeignKeys
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testNoEnforceForeignKeys() throws Exception {
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX)) {
Database db = openCopy(testDB);
db.setEnforceForeignKeys(false);
Table t1 = db.getTable("Table1");
Table t2 = db.getTable("Table2");
Table t3 = db.getTable("Table3");
t1.addRow(20, 0, 20, "some data", 20);
Cursor c = CursorBuilder.createCursor(t2);
c.moveToNextRow();
c.updateCurrentRow(30, "foo30");
c = CursorBuilder.createCursor(t3);
c.moveToNextRow();
c.deleteCurrentRow();
db.close();
}
}
示例10: 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();
}
}
}
示例11: 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;
}
示例12: testDefaults
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testDefaults() throws Exception{
Statement st = null;
try {
st = super.ucanaccess.createStatement();
ResultSet rs= st.executeQuery("SELECT D, E FROM AAA");
while(rs.next()){
assertNotNull(rs.getObject(1));
assertNotNull(rs.getObject(2));
}
Database db=((UcanaccessConnection)super.ucanaccess).getDbIO();
Table tb=db.getTable("AAA");
PropertyMap pm=tb.getColumn("d").getProperties();
assertEquals("NOW()", pm.getValue(PropertyMap.DEFAULT_VALUE_PROP));
PropertyMap pm1=tb.getColumn("a").getProperties();
assertEquals(true, pm1.getValue(PropertyMap.REQUIRED_PROP));
} finally {
if (st != null)
st.close();
}
}
示例13: 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();
}
}
示例14: getSchuetzen
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public static Set<Member> getSchuetzen() {
Set<Member> set = new TreeSet<Member>();
try {
Database db = getDB("data.mdb");
Table table = db.getTable("WettkampfSchuetzen");
for (Row row : table) if ((byte) row.get("Sichtbar") == 1) set.add(new Member(row));
db.close();
} catch (IOException e) {
e.printStackTrace();
}
return set;
}
示例15: getAllSchuetzen
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public static Member[] getAllSchuetzen() {
Vector<Member> list = new Vector<Member>();
try {
Database db = getDB("Kampf.mdb");
Table table = db.getTable("WettkampfSchuetzen");
for (Row row : table) list.add(new Member(row));
db.close();
} catch (IOException e) {
e.printStackTrace();
}
list.sort(null);
return list.toArray(new Member[0]);
}