本文整理汇总了Java中com.healthmarketscience.jackcess.Database.close方法的典型用法代码示例。如果您正苦于以下问题:Java Database.close方法的具体用法?Java Database.close怎么用?Java Database.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Database
的用法示例。
在下文中一共展示了Database.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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);
}
示例3: testInsertLongAutoNumberPK
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testInsertLongAutoNumberPK() throws Exception
{
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
Database db = createMem(fileFormat);
Table table = new TableBuilder("test")
.addColumn(new ColumnBuilder("a", DataType.LONG)
.setAutoNumber(true))
.addColumn(new ColumnBuilder("b", DataType.TEXT))
.setPrimaryKey("a")
.toTable(db);
doTestInsertLongAutoNumber(table);
db.close();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
}
示例8: getAccessTempPath
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public String getAccessTempPath() throws IOException {
if (fileMdb == null||!this.getClass().equals(testingClass)) {
testingClass=this.getClass();
if (this.getAccessPath() == null) {
fileMdb = File.createTempFile("test", ".mdb");
Database db = DatabaseBuilder.create(this.fileFormat, fileMdb);
db.flush();
db.close();
System.out.println("Access file version " + this.fileFormat
+ " created: " + fileMdb.getAbsolutePath());
} else {
fileMdb = copyResourceInTemp(this.getAccessPath());;
}
}
return fileMdb.getAbsolutePath();
}
示例9: 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;
}
示例10: getSupportedForBasename
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public static List<TestDB> getSupportedForBasename(Basename basename,
boolean readOnly) {
List<TestDB> supportedTestDBs = new ArrayList<TestDB>();
for (FileFormat fileFormat :
(readOnly ? SUPPORTED_FILEFORMATS_FOR_READ :
SUPPORTED_FILEFORMATS)) {
File testFile = getFileForBasename(basename, fileFormat);
if(!testFile.exists()) {
continue;
}
// verify that the db is the file format expected
try {
Database db = new DatabaseBuilder(testFile).setReadOnly(true).open();
FileFormat dbFileFormat = db.getFileFormat();
db.close();
if(dbFileFormat != fileFormat) {
throw new IllegalStateException("Expected " + fileFormat +
" was " + dbFileFormat);
}
} catch(Exception e) {
throw new RuntimeException(e);
}
supportedTestDBs.add(new TestDB(testFile, fileFormat));
}
return supportedTestDBs;
}
示例11: testAutoNumberGuid
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testAutoNumberGuid() throws Exception
{
for (final FileFormat fileFormat : SUPPORTED_FILEFORMATS) {
Database db = createMem(fileFormat);
Table table = new TableBuilder("test")
.addColumn(new ColumnBuilder("a", DataType.GUID)
.setAutoNumber(true))
.addColumn(new ColumnBuilder("b", DataType.TEXT))
.toTable(db);
Object[] row = {null, "row1"};
assertSame(row, table.addRow(row));
assertTrue(ColumnImpl.isGUIDValue(row[0]));
row = table.addRow(13, "row2");
assertTrue(ColumnImpl.isGUIDValue(row[0]));
row = table.addRow("flubber", "row3");
assertTrue(ColumnImpl.isGUIDValue(row[0]));
Object[] smallRow = {Column.AUTO_NUMBER};
row = table.addRow(smallRow);
assertNotSame(row, smallRow);
assertTrue(ColumnImpl.isGUIDValue(row[0]));
db.close();
}
}
示例12: close
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void close() throws IOException {
if(_linkedDbs != null) {
for(Database linkedDb : _linkedDbs.values()) {
linkedDb.close();
}
}
_pageChannel.close();
}
示例13: testIndexCodes
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testIndexCodes() throws Exception
{
for (final TestDB testDB : TestDB.getSupportedForBasename(Basename.INDEX_CODES)) {
Database db = openMem(testDB);
for(Table t : db) {
for(Index index : t.getIndexes()) {
// System.out.println("Checking " + t.getName() + "." + index.getName());
checkIndexEntries(testDB, t, index);
}
}
db.close();
}
}
示例14: testReadOnlyFormat
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testReadOnlyFormat() throws Exception {
for (final TestDB testDB : SUPPORTED_DBS_TEST_FOR_READ) {
Database db = null;
Exception failure = null;
try {
db = openCopy(testDB);
if(testDB.getExpectedFormat().READ_ONLY) {
PropertyMap props = db.getUserDefinedProperties();
props.put("foo", "bar");
props.save();
}
} catch(Exception e) {
failure = e;
} finally {
if(db != null) {
db.close();
}
}
if(!testDB.getExpectedFormat().READ_ONLY) {
assertNull(failure);
} else {
assertTrue(failure instanceof NonWritableChannelException);
}
}
}
示例15: testAutoNumberPK
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void testAutoNumberPK() throws Exception
{
for (final TestDB testDB : SUPPORTED_DBS_TEST) {
Database db = openMem(testDB);
Table table = db.getTable("Table3");
doTestAutoNumber(table);
db.close();
}
}