Announcement

Collapse

Mirth Connect 4.1.0 Released!

Mirth Connect 4.1.0 is now available as an appliance update and on our GitHub page. Mirth Connect 4.1.0 includes new features such as new event log messages, additional fields to the Welcome to Mirth Connect screen, new information included in alerts as well as many smaller changes, updates, and improvements. This release also contains several improvements to commercial extensions. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Database Writer - use javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • fleetwoodfc
    replied
    Re: Database Writer - use javascript

    Thanks for the input.
    Seems to be that the problem was partially related to incorrect quotes but also the syntax to use for mapped variables in javascript i.e. $('idpatient&#039 works, while ${idpatient} does not. The following works o.k.

    var expression = "INSERT IGNORE INTO REGISTRATIONS (IDPATIENT,PATIENT_CLASS,REFERRING_DOCTOR,VISIT_NU MBER) VALUES ('"+ $('idpatient&#039 + "','" + $('class&#039 + "','" + $('referringLname&#039 + "','" + $('visitNumber&#039 + "&#039";

    Leave a comment:


  • jeffkeller
    replied
    Re: Database Writer - use javascript


    You might try delimiting your single quotes:

    var var1 = ${idpatient};
    var var2 = ${class};
    var var3 = ${referringLname};
    var var4 = ${idpatient};
    var expression = "INSERT IGNORE INTO REGISTRATIONS (\`IDPATIENT\`,\`PATIENT_CLASS\`, \`REFERRING_DOCTOR\`,\`VISIT_NUMBER\`) VALUES (\`" + var1 + "\`,\`" + var2 + "\`,\`" + var3+ "\`,\`" + var4 + "\`)";


    Leave a comment:


  • fleetwoodfc
    started a topic Database Writer - use javascript

    Database Writer - use javascript

    Trying to insert into a database using the javascript option. This is the script:

    var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('com.mysql.jdbc.Driver','jdbc:mysq l://localhost:3306/MYTABLE','myuser','mypassword& #039;
    var var1 = ${idpatient};
    var var2 = ${class};
    var var3 = ${referringLname};
    var var4 = ${idpatient};
    var expression = "INSERT IGNORE INTO REGISTRATIONS (`IDPATIENT`,`PATIENT_CLASS`, `REFERRING_DOCTOR`,`VISIT_NUMBER`) VALUES (`" + var1 + "`,`" + var2 + "`,`" + var3+ "`,`" + var4 + "`)";
    var result = dbConn.executeUpdate(expression);
    dbConn.close();

    I get the following exception: (I don't think it likes using the mapped variables ${idpatient} etc....)

    Caused by: org.mule.umo.lifecycle.InitialisationException: Initialisation Failure: missing ; before statement (4e4514d1-d1c3-4933-b232-d4bb063cb60b#3)
    at org.apache.commons.digester.Digester.createSAXExce ption(Digester.java:2919)
    at org.apache.commons.digester.Digester.createSAXExce ption(Digester.java:2945)
    at org.apache.commons.digester.Digester.endElement(Di gester.java:1133)
    at org.apache.xerces.parsers.AbstractSAXParser.endEle ment(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser .parse(Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1685)
    at org.mule.config.builders.AbstractDigesterConfigura tion.process(AbstractDigesterConfiguration.java:11 9)
    ... 5 more

    Can anyone help!!!!

Working...
X