maryam
maryam

Reputation: 584

Using Mule Studio to read CSV

i try this example : Using Mule Studio to read CSV step by step but but content of csv donot copy to database . i have not any errors i left my console and 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>

my console:

.....

**********************************************************************
* 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'                                        +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

console csv

Upvotes: 1

Views: 1436

Answers (1)

maryam
maryam

Reputation: 584

I could take good result and csv file converted to database.

I had 2 mistakes:

  1. after run program, .csv file cleaned from path and I did not and run the program again without .csv file

  2. name of fields in queries xml was difference to name of columns in database

Upvotes: 1

Related Questions