public static void main(String args[]){
// 1.打开指定工作空间
Workspace workspace = new Workspace();
WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
workspaceConnectionInfo.setType(WorkspaceType.SMWU);
String file = "C:/CAD/testCAD.smwu";
workspaceConnectionInfo.setServer(file);
workspace.open(workspaceConnectionInfo);
// 2.由工作空间打开数据源
Datasource datasource = workspace.getDatasources().get(0);
System.out.println(datasource.getConnectionInfo());
// 3.数据源执行导入数据集
ImportSettingDWG importSettingDWG = new ImportSettingDWG();
importSettingDWG.setImportMode(ImportMode.OVERWRITE);
importSettingDWG.setImportingAsCAD(false);
importSettingDWG.setTargetDatasource(datasource);
importSettingDWG.setSourceFilePath("C:/1.dwg");
importSettingDWG.setImportingExternalData(true);
importSettingDWG.setImportingByLayer(true);
DataImport dataImport = new DataImport();
dataImport.getImportSettings().add(importSettingDWG);
ImportResult importResult = dataImport.run();
ImportSetting[] impt = importResult.getFailedSettings();
System.out.println(datasource.isConnected());
if (impt.length != 0)
{
System.out.println("导入失败!");
}else{
System.out.println("导入成功!");
}
// 释放资源
workspaceConnectionInfo.dispose();
workspace.close();
workspace.dispose();
}
这样一个测试方法,想要将dwg文件导入到工作空间的oracle型数据源中,但是导入失败,实在想不出哪里出了问题,拜托各位帮忙解释一下,谢谢!