1

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>
halfer
  • 19,824
  • 17
  • 99
  • 186
Jad
  • 479
  • 2
  • 10
  • 23
  • Since you're using the Enterprise Edition, you can reach MuleSoft's professional support and get a timely help for your issue. Anyway, can you post the full stacktrace you get for this mysterious "Duplicated Database" error? – David Dossot Jul 20 '14 at 23:07
  • for the duplicated database, after I copy and paste any xml provided in any example, the flow shows me a "duplicated database" with warning sign on the db pic (!). since I got this, I didn't try to continue with running the app as I read in the web, this happen cause it was supported in previous versions, so some expressions has been updated in the current version and we should update the xml according to that. should say, I didn't purchase Mule EE. I only download, so I think it's trial! so I don't think I can get a support from them :) – Jad Jul 21 '14 at 06:12
  • OK, so the "Duplicated Database" error seems to be reported by Studio not by Mule. Not sure what it means. What does the inbound XML message look like? – David Dossot Jul 21 '14 at 16:55
  • 1
    @user37: I don't think Deprecated database is an issue .. Even I get the same for the apps that I have created on older Mule like Mule 3.4 and now currently running on Mule 3.5 .. but anyway I used to get the results from those Deprecated databases ... – Anirban Sen Chowdhary Jul 22 '14 at 05:31
  • @AnirbanSenChowdhary Thanks for your reply! then I can continue even if there is a warning sign on the DB, right? That's good! – Jad Jul 22 '14 at 05:40
  • 1
    Spring beans are used to configure objects that are not configured by Mule itself, like datasources in this case. For FTP, refer to the user guide: http://www.mulesoft.org/documentation/display/current/FTP+Transport+Reference – David Dossot Jul 22 '14 at 15:39
  • Mr. @DavidDossot , We come back to what I posted in the question, it isn't working. That's why I am asking you for help, please! In my XML, Mule asks to check split expression, what I don't know. and it is showing splitter returned no results! – Jad Jul 22 '14 at 17:31
  • That's what I asked for the XML message (see above comment). The `foreach` expression seems wrong. – David Dossot Jul 22 '14 at 17:52
  • I meant the XML payload of the message before the `foreach` – David Dossot Jul 22 '14 at 18:27
  • @DavidDossot , I tried to download the file to a local folder, when I send the file, it is coming to the folder as .dat file, and with 0 bytes and with strange name! when I tried to add == outputPattern="#[message.inboundProperties['filename']]" == it bought the file as file format, with name of null, and 0 bytes too! so it's coming empty regardless of the format. please, help – Jad Jul 22 '14 at 19:27
  • I'm talking about the XML payload of the message right before it hits the `foreach` loop, that way we can help you fixing its `xpath` expression. – David Dossot Jul 23 '14 at 04:01
  • Also you enumerate a large number of unrelated issues in comments: I suggest you try first to make the simple HTTP-based flow above work before starting to throw FTP in the mix. Also spending some time reading the Mule user guides / books out there could help you getting a better understanding of the fundamentals before diving right in into building something... – David Dossot Jul 23 '14 at 04:03
  • @DavidDossot, I edited the question, to include the screenshots of the inbound message payload. Please, check them, waiting your suggestions, thanks in advance! – Jad Jul 23 '14 at 12:21
  • 1
    Where you've put the breakpoint, the payload is a byte array, which us unreadable. Add a logger after the transformation to string and copy/paste the payload in the question. – David Dossot Jul 23 '14 at 13:57
  • Unfortunately, this is not the payload you have posted but the String rendering of the whole message... – David Dossot Jul 23 '14 at 15:29

1 Answers1

1

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.

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • how to prevent Mule from deleting the file in the FTP after move it to a local folder? (Mule EE) I've searched but moveToDirectory is only for FILE connector, but I have FTP one. Thanks! – Jad Jul 30 '14 at 13:06
  • 1
    `moveToDirectory` is also available for FTP EE, as you can see here: http://www.mulesoft.org/documentation/display/current/FTP+Transport+Reference#FTPTransportReference-MuleEnterpriseConnectorAttributes – David Dossot Jul 30 '14 at 16:00
  • Thanks Mr. Dossot. But, when I used `moveToDirectoty`, Mule is stopping processing the rest. Mule is moving the file, but not inserting it in DB. how to go with both ways together, please? – Jad Aug 02 '14 at 18:38
  • 1
    Please open a new question for this issue. – David Dossot Aug 02 '14 at 20:39
  • Mr.Dossot, please, check [this question](http://stackoverflow.com/questions/25107127/movetodirectory-errors-mule).Thanks! – Jad Aug 03 '14 at 17:18