【问题标题】:how to insert all records of excel sheet into sql data base using wso2 dss 6.4.0?如何使用 wso2 dss 6.4.0 将 excel 表的所有记录插入 sql 数据库?
【发布时间】:2023-04-01 05:45:01
【问题描述】:

我是 wso2 6.4.0 的新手。我必须将excel数据插入sql,所以我选择wso2 dss。使用 dss 记录正确获取并插入但仅插入一条记录(仅顶部一条)仍然会跳过记录。我还使用嵌套查询选项来检索和插入。

<query id="readExcelData" useConfig="excelConfig">  
<excel>
<workbookname>sheet1</workbookname>
<hasheader>true</hasheader>
<startingrow>2</startingrow>
<maxrowcount>-1</maxrowcount>
<headerrow>1</headerrow>
</excel>
<result element="Products" rowName="Product">           
<element column="ID" name="ID" xsdType="xs:string"/>
<element column="Model" name="Model" xsdType="xs:string"/>
<element column="Classification" name="Classification" xsdType="xs:string"/>
<call-query href="insertIntoSql" requiredRoles="">      
<with-param name="ID" query-param="ID" />
<with-param name="Model" query-param="Model" />
<with-param name="Classification" query-param="Classification" />
</call-query>
</result>    
</query>
<operation name="excelFileProcessing" returnRequestStatus="true">
<call-query href="readExcelData"/>          
</operation>
<query id="insertIntoSql" useConfig="sqlConfig">                                    
<sql>insert into dbo.myProductList(ID,Model,Classification) values(:ID,:Model,:Classification)</sql>                                    
<param name="ID" sqlType="STRING" />                                    
<param name="Model" sqlType="STRING" />                                    
<param name="Classification" sqlType="STRING" />                  
</query>

【问题讨论】:

    标签: wso2 wso2esb wso2dss


    【解决方案1】:

    从 Excel 工作表中检索记录后,您将获得记录集。因此,您必须编写一个突触配置来插入每条记录。为此,您已经迭代了 excel 工作表数据的有效负载(对于每条记录)并插入。您可以使用iterate mediator。例如,您可以实现类似于 this 的东西。

    你可以关注,

    1. 在代理服务/API 中调用数据服务来获取 excel 表的 数据。
    2. 遍历结果集。
    3. 在每次迭代中,创建 有效载荷将数据插入数据库并调用数据服务来调用 插入数据查询。
    4. 调用代理服务/API。

    【讨论】:

    • 您好,首先感谢您。 excel表中的所有记录都正确插入到db中。之后我更改了 sql 连接器,它工作正常。我用“net.sourceforge.jtds.jdbc.Driver”这个代替了“com.microsoft.sqlserver.jdbc.SQLServerDriver”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多