[英]Apache MetaModel DataContext.getDefaultSchema not working
我目前正在使用针对Java 1.8的Apache MetaModel 4.6.0 API。 我在获取要使用的DataContext的默认架构时遇到麻烦。 以下是我的代码段:
private DataContext dataContext;
private Schema schema;
private Table table;
/**
* @brief Constructor that takes in an excel file
* @detail Creates a schema for the excel file to be easily queried
* @param excelFile
*/
public ExcelQuery(File file)
{
dataContext = new ExcelDataContext(file);
schema = dataContext.getDefaultSchema();
table = schema.getTables()[0];
}
当涉及到这一部分时:
schema = dataContext.getDefaultSchema();
该代码只是挂起试图执行此操作。 任何想法为什么会这样?
我的目标是能够使用此API查询Excel文件。 我已经看到许多示例可以做到这一点并起作用,但是似乎无法重新创建它。
如您所说的DataContext.getDefaultSchema不起作用尝试通过使用打印所有架构
Schema[] schema = dc.getSchemas();
然后尝试使用正确的schemaName。
Schema schema = dc.getSchemaByName(schemaName);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.