2015-03-31 41 views
0

Im使用orient db,我必須使用java導出指定的數據表。這裏是代碼即時通訊工作:Orient DB - 使用指定的數據表導出數據庫

ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/sampleDB").open("admin", "admin"); 

     try { 
      OCommandOutputListener listener = new OCommandOutputListener() { 
       @Override 
       public void onMessage(String iText) { 
        // System.out.print(iText); 
       } 
      }; 

      Set<String> abcd = new HashSet<String>(); 
      abcd.add("sample_demo1_OnlineShopping"); 

      System.out.println(abcd); 

      ODatabaseExport export = new ODatabaseExport(db, "DataCont/Data.gz", listener); 

      export.setIncludeInfo(false); 
      export.setIncludeClusterDefinitions(false); 
      export.setIncludeSchema(false); 
      export.setIncludeIndexDefinitions(false); 
      export.setIncludeManualIndexes(false); 

      export.setIncludeClasses(abcd); 

//   export.exportRecords(); 
      export.exportDatabase(); 
      export.close(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } finally { 
      db.close(); 
     } 

問題是,它不包括任何類。輸出文件是這樣的:

{"records":[]} 

但是,當我嘗試沒有「setIncludeClasses」它打印數據庫中可用的所有類。這個問題會有什麼問題。提前致謝。

回答

1

改變這一行到:

abcd.add("sample_demo1_OnlineShopping".toUpperCase()); 

我還沒有找到它的文檔中,但includeClasses期待以大寫類(同爲excludeClasses)。

請參閱the source code

+0

它的工作原理。謝啦。但有一個問題。它只檢索指定的類。它不檢索它的子類。這應該是或有我的代碼中的任何問題。 – Vithushan 2015-03-31 14:44:20

+0

我在答案中鏈接的源代碼似乎並不關心子類。 – vitorenesduarte 2015-03-31 15:07:37