I need to insert .csv file into MYSQL database. All the examples on the web, give me "Deprecated Database" and then no solutions!
The HTML inbound endpoint is to send the csv file using postman plugin (chrome). when running the app, the console is showing this warning:
org.mule.routing.ExpressionSplitter: Splitter returned no results. If this is not expected, please check your split expression
even when I add a splitter after the Byte Array to String, and the expression is #[xpath('//item')]
, it keeps showing same warning!
I have MuleESB enterprise. All connections with database is correct.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jdbc-ee="http://www...
<db:mysql-config name="MySQL_Configuration" host="localhost"
port="3306" database="dbflow"
doc:name="MySQL Configuration" user="root"/>
<data-mapper:config name="CSV_To_XML" transformationGraphPath="csv_to_xml.grf" doc:name="CSV_To_XML"/>
<jdbc-ee:mysql-data-source name="MySQL_Data_Source" user="User" password="Pass" url="jdbc:mysql://localhost:3306/dbflow" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<flow name="dbFlow1" doc:name="dbFlow1">
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8084" path="csv" doc:name="HTTP"/>
<data-mapper:transform config-ref="CSV_To_XML" doc:name="CSV To XML"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<foreach collection="#[xpath('//info')]" doc:name="For Each">
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[INSERT INTO `dbflow`.`user_table`
(`current_date`,
`serialnumber`,
`gender`,
`fullname`,
`birthdate`,
`email`,
`mobilnumber`,
`address`)
VALUES
(#[xpath://date],
#[xpath://serialnumber],
#[xpath://gender],
#[xpath://fullname],
#[xpath://birthdate],
#[xpath://email],
#[xpath://mobilenumber],
#[xpath://address]
);]]></db:parameterized-query>
</db:insert>
</foreach>
</flow>
</mule>
From the discussions, it seems the core issue is that the HTTP POSTed content ends up producing this XML:
<?xml version="1.0" encoding="UTF-8"?>
<infos/>
which explains why the for-each
doesn't produce anything.
The solution consists in HTTP POSTing a valid non-empty CSV entity.