com.healthmarketscience.jackcess.Database.close()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中com.healthmarketscience.jackcess.Database.close()方法的一些代码示例,展示了Database.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.close()方法的具体详情如下:
包路径:com.healthmarketscience.jackcess.Database
类名称:Database
方法名:close

Database.close介绍

[英]Close the database file (and any linked databases). A Database must be closed after use or changes could be lost and the Database file corrupted. A Database instance should be treated like any other external resource which would be closed in a finally block (e.g. an OutputStream or jdbc Connection).
[中]关闭数据库文件(以及所有链接的数据库)。数据库在使用后必须关闭,否则更改可能会丢失,并且数据库文件已损坏。数据库实例应被视为在finally块中关闭的任何其他外部资源(例如OutputStream或jdbc连接)。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

  1. void closeDatabase() throws IOException {
  2. db.close();
  3. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. public void dispose( StepMetaInterface smi, StepDataInterface sdi ) {
  2. meta = (AccessInputMeta) smi;
  3. data = (AccessInputData) sdi;
  4. if ( data.t != null ) {
  5. data.t = null;
  6. }
  7. if ( data.rw != null ) {
  8. data.rw = null;
  9. }
  10. if ( data.readrow != null ) {
  11. data.readrow = null;
  12. }
  13. try {
  14. if ( data.d != null ) {
  15. data.d.close();
  16. data.d = null;
  17. }
  18. if ( data.file != null ) {
  19. data.file.close();
  20. data.file = null;
  21. }
  22. data.daf = null;
  23. } catch ( Exception e ) {
  24. // ignore this
  25. }
  26. super.dispose( smi, sdi );
  27. }

代码示例来源:origin: pentaho/pentaho-kettle

  1. try {
  2. if ( db != null ) {
  3. db.close();

代码示例来源:origin: pentaho/pentaho-kettle

  1. database.close();

代码示例来源:origin: pentaho/pentaho-kettle

  1. db.close();

代码示例来源:origin: pentaho/pentaho-kettle

  1. accessDatabase.close();

代码示例来源:origin: org.integratedmodelling/klab-common

  1. @Override
  2. public void run() {
  3. try {
  4. if (_db != null) {
  5. _db.close();
  6. }
  7. } catch (IOException e) {
  8. }
  9. }
  10. });

代码示例来源:origin: ujmp/universal-java-matrix-package

  1. public void close() throws IOException {
  2. database.close();
  3. }

代码示例来源:origin: dk.eobjects.metamodel/MetaModel-access

  1. @Override
  2. protected void finalize() throws Throwable {
  3. super.finalize();
  4. _database.close();
  5. }
  6. }

代码示例来源:origin: org.eobjects.metamodel/MetaModel-access

  1. @Override
  2. protected void finalize() throws Throwable {
  3. super.finalize();
  4. _database.close();
  5. }
  6. }

代码示例来源:origin: apache/tika

  1. if (db != null) {
  2. try {
  3. db.close();
  4. } catch (IOException e) {

代码示例来源:origin: com.healthmarketscience.jackcess/jackcess

  1. @Override
  2. public void close() throws IOException {
  3. if(_linkedDbs != null) {
  4. for(Database linkedDb : _linkedDbs.values()) {
  5. linkedDb.close();
  6. }
  7. }
  8. _pageChannel.close();
  9. }

代码示例来源:origin: AccelerationNet/access2csv

  1. static void export(File inputFile, String tableName, boolean withHeader, File outputDir, String csvPrefix, boolean applyQuotesToAll, String nullText) throws IOException{
  2. Database db = DatabaseBuilder.open(inputFile);
  3. try{
  4. export(db, tableName, new FileWriter(new File(outputDir, csvPrefix + tableName + ".csv")), withHeader, applyQuotesToAll, nullText);
  5. }finally{
  6. db.close();
  7. }
  8. }

代码示例来源:origin: AccelerationNet/access2csv

  1. static void exportAll(File inputFile, boolean withHeader, File outputDir, String csvPrefix, boolean applyQuotesToAll, String nullText) throws IOException{
  2. Database db = DatabaseBuilder.open(inputFile);
  3. try{
  4. for(String tableName : db.getTableNames()){
  5. String csvName = csvPrefix + tableName + ".csv";
  6. File outputFile = new File(outputDir, csvName);
  7. Writer csv = new FileWriter(outputFile);
  8. try{
  9. System.out.println(String.format("Exporting '%s' to %s",
  10. tableName, outputFile.toString()));
  11. int rows = export(db, tableName, csv, withHeader, applyQuotesToAll, nullText);
  12. System.out.println(String.format("%d rows exported", rows));
  13. }finally{
  14. try{
  15. csv.flush();
  16. csv.close();
  17. }catch(IOException ex){}
  18. }
  19. }
  20. }finally{
  21. db.close();
  22. }
  23. }

代码示例来源:origin: net.sf.ucanaccess/ucanaccess

  1. void shutdown(Session _session) throws Exception {
  2. DBReferenceSingleton.getInstance().remove(this.dbFile.getAbsolutePath());
  3. if (this.immediatelyReleaseResources) {
  4. for (OnReloadReferenceListener listener : onReloadListeners) {
  5. listener.onReload();
  6. }
  7. }
  8. this.memoryTimer.timer.cancel();
  9. this.dbIO.flush();
  10. this.dbIO.close();
  11. this.closeHSQLDB(_session);
  12. }

代码示例来源:origin: ujmp/universal-java-matrix-package

  1. public static final JackcessDenseObjectMatrix2D toFile(File file, Object... parameters)
  2. throws IOException {
  3. Database db = DatabaseBuilder.open(file);
  4. Set<String> tables = db.getTableNames();
  5. String tablename = null;
  6. if (parameters.length != 0) {
  7. tablename = StringUtil.convert(parameters[0]);
  8. }
  9. if (tablename == null) {
  10. if (tables.size() == 1) {
  11. tablename = db.getTableNames().iterator().next();
  12. }
  13. }
  14. db.close();
  15. if (tablename == null) {
  16. throw new IllegalArgumentException(
  17. "please append the table name, i.e. one of these tables: " + tables);
  18. }
  19. return new JackcessDenseObjectMatrix2D(file, tablename);
  20. }

代码示例来源:origin: net.sf.ucanaccess/ucanaccess

  1. public void reloadDbIO() throws IOException {
  2. this.dbIO.flush();
  3. this.dbIO.close();
  4. for (OnReloadReferenceListener listener : onReloadListeners) {
  5. listener.onReload();
  6. }
  7. this.dbIO = open(dbFile, this.pwd);
  8. }

代码示例来源:origin: AccelerationNet/access2csv

  1. static void schema(File inputFile) throws IOException{
  2. Database db = DatabaseBuilder.open(inputFile);
  3. try{
  4. for(String tableName : db.getTableNames()){
  5. Table table = db.getTable(tableName);
  6. System.out.println(String.format("CREATE TABLE %s (", tableName));
  7. for(Column col : table.getColumns()){
  8. System.out.println(String.format(" %s %s,",
  9. col.getName(), col.getType()));
  10. }
  11. System.out.println(")");
  12. }
  13. }finally{
  14. db.close();
  15. }
  16. }

代码示例来源:origin: net.sf.ucanaccess/ucanaccess

  1. private boolean checkInside() throws IOException {
  2. boolean reload = checkInside(this.dbIO);
  3. if (reload) {
  4. return true;
  5. }
  6. for (File fl : this.links) {
  7. Database db = DatabaseBuilder.open(fl);
  8. reload = checkInside(db);
  9. db.close();
  10. if (reload) {
  11. return true;
  12. }
  13. }
  14. return false;
  15. }

代码示例来源:origin: net.sf.ucanaccess/ucanaccess

  1. private static boolean hasPassword(File fl) throws IOException {
  2. Database db;
  3. try {
  4. db = DatabaseBuilder.open(fl);
  5. } catch (IOException e) {
  6. DatabaseBuilder dbb = new DatabaseBuilder();
  7. dbb.setReadOnly(true);
  8. dbb.setFile(fl);
  9. db = dbb.open();
  10. }
  11. String pwd = db.getDatabasePassword();
  12. db.close();
  13. return pwd != null;
  14. }

相关文章