1

我试试这个例子: 使用 Mule Studio 逐步读取 CSV,但 csv 的内容不会复制到数据库。我离开控制台和 myflow 没有任何错误:

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

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jdbc="http://www.mulesoft.org/schema/mule/jdbc" 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="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
http://www.mulesoft.org/schema/mule/jdbc http://www.mulesoft.org/schema/mule/jdbc/current/mule-jdbc.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 ">

   <configuration doc:name="Configuration">
        <expression-language autoResolveVariables="true">
            <import class="org.mule.util.StringUtils" />
        </expression-language>
    </configuration>


    <jdbc:mysql-data-source name="MySQL_Data_Source" user="roor" url="jdbc:mysql://localhost:3306/csv" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source" password="1234"/>


    <jdbc:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
        <jdbc:query key="InsertRecord" value="INSERT INTO &quot;tblFamily&quot;(&quot;Title&quot;, &quot;FirstName&quot;, &quot;LastName&quot;) VALUES (#[message.payload[0]],#[message.payload[1]],#[message.payload[2]])"/>
    </jdbc:connector>
    <flow name="csvFlow1" doc:name="csvFlow1">
     <!-- Step 1: CSV file source -->
    <file:inbound-endpoint path="C:\Users\masoudy\Downloads\Compressed\Resoes" pollingFrequency="5000" doc:name="Source"/>
        <!-- Step 2: Convert between object arrays and strings -->
    <object-to-string-transformer doc:name="Object to String"/>
        <splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter"/>
    <expression-transformer expression="#[StringUtils.split(message.payload, ',')]" doc:name="Expression"/>
        <jdbc:outbound-endpoint exchange-pattern="one-way" queryTimeout="-1" doc:name="Destination" connector-ref="Database" queryKey="InsertRecord"/>

</flow>


</mule>

我的控制台:

......

**********************************************************************
* Application: csv                                                   *
* OS encoding: Cp1256, Mule encoding: UTF-8                          *
*                                                                    *
* Agents Running:                                                    *
*   JMX Agent                                                        *
**********************************************************************
INFO  2013-04-22 14:55:54,437 [main] org.mule.module.launcher.DeploymentService: 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Started app 'csv'                                        +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

控制台 csv

4

1 回答 1

1

我可以取得好的结果并将 csv 文件转换为数据库。

我有两个错误:

  1. 运行程序后,.csv文件从路径中清除,我没有,在没有.csv文件的情况下再次运行程序

  2. 查询 xml 中的字段名称与数据库中的列名称不同

于 2013-04-23T08:39:12.600 回答