简体   繁体   English

Apache MetaModel DataContext.getDefaultSchema不起作用

[英]Apache MetaModel DataContext.getDefaultSchema not working

I am currently using Apache's MetaModel 4.6.0 API for Java 1.8. 我目前正在使用针对Java 1.8的Apache MetaModel 4.6.0 API。 I am having trouble getting the default schema for the DataContext I want to use. 我在获取要使用的DataContext的默认架构时遇到麻烦。 Below is a snippet my code: 以下是我的代码段:

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];
}

When it gets to this part: 当涉及到这一部分时:

schema = dataContext.getDefaultSchema();

The code just hangs trying to perform this action. 该代码只是挂起试图执行此操作。 Any ideas why this would be happening? 任何想法为什么会这样?

My goal is to be able to query an excel file using this API. 我的目标是能够使用此API查询Excel文件。 I have seen many examples do this and work, but can't seem to recreate it. 我已经看到许多示例可以做到这一点并起作用,但是似乎无法重新创建它。

as you said DataContext.getDefaultSchema is not working Try to print all the schema by using 如您所说的DataContext.getDefaultSchema不起作用尝试通过使用打印所有架构

Schema[] schema = dc.getSchemas();

then try the correct schemaName. 然后尝试使用正确的schemaName。

Schema schema = dc.getSchemaByName(schemaName);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM