Java 如何在Mule 3.4 ESB中使用Datamapper在数据库中映射Excel文件

Java 如何在Mule 3.4 ESB中使用Datamapper在数据库中映射Excel文件,java,excel,mule,esb,mule-studio,Java,Excel,Mule,Esb,Mule Studio,大家早上好, 我对Mule ESB中的Datamapper组件有一个大问题。 我正在尝试将Excel文件(xlsx)映射到oracle数据库的表中。 为此,我使用Oracle数据源及其所有内容创建了一个JDBC连接器,但当我转到DataMapper向导创建映射时,我无法选择创建的连接器,因为连接器列表(在输出DataMapper向导标签中)中没有任何项。[下面是我的问题的屏幕截图] 我真的不明白为什么, 你能帮我吗 此外,我还有一个问题要问您:除了xls文件提供的字段之外,我还需要在数据库中插

大家早上好,

我对Mule ESB中的Datamapper组件有一个大问题。 我正在尝试将Excel文件(xlsx)映射到oracle数据库的表中。 为此,我使用Oracle数据源及其所有内容创建了一个JDBC连接器,但当我转到DataMapper向导创建映射时,我无法选择创建的连接器,因为连接器列表(在输出DataMapper向导标签中)中没有任何项。[下面是我的问题的屏幕截图]

我真的不明白为什么, 你能帮我吗

此外,我还有一个问题要问您:除了xls文件提供的字段之外,我还需要在数据库中插入其他字段,如MuleMessageID、xls文件名和Oracle SYSDATE。可能吗

为了向您提供尽可能多的信息,我将发布我的mule项目

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd">
    <spring:beans>
        <spring:bean id="SettingProperty" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" scope="singleton">
            <spring:property name="locations">
                <spring:list>
                    <spring:value>classpath:pilot.properties</spring:value>
                </spring:list>
            </spring:property>
        </spring:bean>
    </spring:beans>

    <http:connector name="HTTPConnector" 
                    cookieSpec="netscape" 
                    doc:name="HTTP\HTTPS">
        <service-overrides messageFactory="it.aizoon.http.customHttpMultipart.MyHttpMultipartMuleMessageFactory"/>          
    </http:connector>

    <file:endpoint path="${file.output}" name="XSLXFile" responseTimeout="10000" doc:name="File"/>

    <jdbc-ee:oracle-data-source name="Oracle_Data_Source" user="${db.user}" password="${db.password}" url="${db.url}" doc:name="Oracle Data Source" transactionIsolation="UNSPECIFIED"/>
    <jdbc-ee:connector name="JdbcConnector" dataSource-ref="Oracle_Data_Source" validateConnections="true" queryTimeout="-1" doc:name="Database" pollingFrequency="0">
        <jdbc-ee:query key="storedProc" value="CALL ${db.storedProc}" />
    </jdbc-ee:connector>
    <data-mapper:config name="xls_to_db_grf" transformationGraphPath="xls_to_db.grf" doc:name="xls_to_db_grf"/>

    <!-- Starting Flow Declaration -->
    <flow name="zonal_imbalance_1.0Flow1" doc:name="zonal_imbalance_1.0Flow1">
        <http:inbound-endpoint 
            address="http://${conn.host}:${conn.port}/${conn.path}"
            connector-ref="HTTPConnector" doc:name="HTTP" exchange-pattern="request-response"/>
        <wildcard-filter pattern="*/${conn.path}*" caseSensitive="true" doc:name="Wildcard"/>
        <file:outbound-endpoint responseTimeout="10000" doc:name="Store XSLX File" path="C:\Users\paride.letizia\MuleStudio\workspace_ee\zonal_imbalance_1.0\src\test\resources\outputFolder"/>
        <data-mapper:transform doc:name="DataMapper"/>
        <jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryTimeout="-1"  doc:name="ORACLE Database" queryKey="example" connector-ref="JdbcConnector">
            <jdbc-ee:query key="example" value="SELECT * FROM prova;"/>
        </jdbc-ee:outbound-endpoint>
</flow>
</mule>

类路径:pilot.properties
提前,非常非常感谢你们所有人。
我期待着收到您的来信。

我不知道他们决定添加JDBC“连接器”的确切原因,但它们实际上并没有连接器的功能。连接器用于使用特殊API与非标准服务建立连接,因此,为了与Oracle DB建立连接,只需遵循标准方法即可

有关更多详细信息,请参阅Anypoint文档,特别是名为“端点和连接器”的段落:

连接器通过传输发送和接收数据,其功能类似于端点。然而,尽管端点对于广泛使用的协议(如JDBC、FTP、HTTP、POP3等)是通用的,但每个连接器都是为了优化与特定第三方API(如Salesforce或Twitter)的连接而构建的

在大多数情况下,当您连接到具有标准格式或协议的外部资源时,端点满足您的需要。例如,如果要连接到Oracle数据库或MS SQL数据库,则可以使用数据库端点,因为这些数据库以标准格式输出数据;不需要Oracle或MS SQL连接器。类似地,对于特定类型的文件(如.csv文件),不需要连接器。文件端点可以配置为以任何类型的文本文件格式(包括.csv)输入和输出数据,因此不需要csv连接器


相关:

嗨,有人能帮我吗?你是怎么解决的?