首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache Calcite | HSQLDB -未找到表异常

Apache Calcite | HSQLDB -未找到表异常
EN

Stack Overflow用户
提问于 2018-06-05 18:29:06
回答 1查看 95关注 0票数 0

我正在尝试通过遵循存储层为HSQLDB的RelBuilderExample来学习Apache Calcite。不幸的是,当我调用Apache方解石的builder.scan(tableName)接口时,我一直收到“表未找到异常”的提示。当我直接使用ResultSet rs = statement.executeQuery("SELECT * from file");查询HSQL中的数据时,我就能够检索数据了。相关代码如下:

代码语言:javascript
复制
//I create an instance of RelBuilder using the Config defined below
RelBuilder builder = RelBuilder.create(config().build());
//This line throws me exception: org.apache.calcite.runtime.CalciteException: Table 'file' not found

            builder = builder.scan("file");

/**
  Building the configuration backed by HSQLDB
*/
public static Frameworks.ConfigBuilder config() throws Exception{

            //Getting the ConnectionSpec for the in memory HSQLDB
            //FileHSQLDB.URI = "jdbc:hsqldb:mem:intel"
            //FileHSQLDB.USER = "user"
            //FileHSQLDB.PASSWORD = "password"
            final ConnectionSpec cs = new ConnectionSpec(FileHSQLDB.URI, FileHSQLDB.USER, FileHSQLDB.PASSWORD, "org.hsqldb.jdbcDriver", "intel");

            //cs.url = "jdbc:hsqldb:mem:intel"
            //cs.driver = "org.hsqldb.jdbcDriver"
            //cs.username = "user"
            //cs.password = "password"
            DataSource dataSource = JdbcSchema.dataSource(cs.url, cs.driver, cs.username, cs.password);
            Connection connection = dataSource.getConnection();
            Statement statement = connection.createStatement();
            //This returns me 3 results
            ResultSet rs = statement.executeQuery("SELECT * from file");
            while(rs.next()) {
                String id = rs.getString("file_id");
                System.out.println(id);
            }
            // Next I create the rootSchema
            SchemaPlus rootSchema = Frameworks.createRootSchema(true);

            //I suspect that there is some issue in the below line. I think I 
            //am not using Apache Calcite APIs properly, but not sure what I 
            //am doing wrong.
            rootSchema.add("intel", JdbcSchema.create(rootSchema, "intel", dataSource, cs.catalog, cs.schema));
return Frameworks.newConfigBuilder().defaultSchema(rootSchema);

谁能帮帮我,我可能做错了什么。

EN

回答 1

Stack Overflow用户

发布于 2018-06-05 20:11:47

如果您的表为file (小写),请确保在查询中引用表名,即"SELECT * from \"file\""

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50697860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档