【问题标题】:Teiid Springboot starter file datasourceTeiid Springboot 启动文件数据源
【发布时间】:2020-10-16 09:28:51
【问题描述】:

使用 Teiid Springboot 我想使用磁盘中的 xml 文件。我曾经使用旧的 EAP/Wildfly Teiid 项目,解决这个问题的方法是使用资源适配器,然后调用程序来读取数据。

使用 Springboot,我需要采取哪些步骤来创建可在我的 DDL VDB 中使用的数据源/资源适配器。 我已经看过下面的 FTP 示例,所以我的假设是创建一个 FileConnectionFactory: https://github.com/teiid/teiid-spring-boot/tree/master/samples/ftp 但是,没有使用 DDL 文件,我的偏好是在 DDL 中解析 XML(除非有更好的方法在我的 DDL 中公开这些数据)。

【问题讨论】:

    标签: xml spring-boot file teiid


    【解决方案1】:

    使用基于 DDL 的 VDB 时,您可以通过在 application.properties 中提供以下属性来定义基于文件的连接

    spring.teiid.file.foo.parent-directory=path/to/myfile
    

    其中foo是你的文件资源名,需要在VDB中使用,例如:(accounts是给schema的名字)

    CREATE SERVER foo FOREIGN DATA WRAPPER file;
    CREATE SCHEMA accounts SERVER foo;
    

    然后在视图转换中,您可以使用上述架构并将文件读取为

    create view something(...) AS
      select x.* from 
        (exec accounts.getTextFiles()) f, 
        xmltable('/a' PASSING xmlparse(document f.file) COLUMNS first string, second integer) x
    

    有关使用xmltable 的更多详细信息,请参阅http://teiid.github.io/teiid-documents/master/content/reference/r_xmltable.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 2019-12-05
      • 1970-01-01
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多