I am currently using Apache's MetaModel 4.6.0 API for Java 1.8. I am having trouble getting the default schema for the DataContext I want to use. 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. 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
Schema[] schema = dc.getSchemas();
then try the correct schemaName.
Schema schema = dc.getSchemaByName(schemaName);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.