I am completely new to working with Mirth, JavaScript, and MySQL. I have successfully set up a channel in Mirth to read a text file and convert it to XML. Everything is functioning properly so far. I also attempted to send the XML data to a MySQL database using the Database Writer in another channel.
Here is an example of the JavaScript code:
var dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.jdbc.Driver','jdbc:mysql://192.168.1.4:3306/mirth','root','');
var result = dbConn.executeUpdate('INSERT INTO jon (xml) values ('1234')');
dbConn.close();
The above code successfully inserts a record into the 'jon' table with the value of '1234'. However, my main question is how can I send the XML that I have read through the channel reader source to the database? I have tried replacing '1234' with ('+messageObject.getEncodedData()+), rawdata, or transformeddata, but none of these options are working. Instead, I am encountering the following error:
ERROR (org.mule.impl.DefaultComponentExceptionStrategy:95) .... Wrapped com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<?xml version="1.0" encoding="UTF-8"?><delimited><row><column1>1234</column1><co' at line 1 (1cf6717f-4818-4b18-acb2-3b93079f2e95#7) .....
My goal is to store the entire XML in one field without any parsing necessary at this stage. Thank you for your understanding. Best regards, janmohamamdi