web stats
Problem with JavaScript SQL statement - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-10-2013, 12:50 PM
rparkinson rparkinson is offline
What's HL7?
 
Join Date: Dec 2013
Posts: 5
rparkinson is on a distinguished road
Default Problem with JavaScript SQL statement

I am attempting to read a frequency from an RXE segment, pass it into a SQL query to return a result from the DB. Then put the result into an RGV segment of the outbound message. Getting an error

DETAILS: Wrapped java.lang.ArrayIndexOutOfBoundsException: -1

code is:
var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://ACNU3159HDS:1433/mirthdb2','mirthuser','mirthuser');

var FreqID;
FreqID = msg['RXE']['RXE.1']['RXE.1.2']['RXE.1.2.1'].toString();
var expression = "SELECT HOURS from FREQ_TIMES WHERE FREQ_ID = '" + FreqID + "'";
var result = dbConn.executeCachedQuery(expression);

result.first();
var GiveTime = result.getInt(1);
tmp['RXG']['RXG.3'][0]['RXG.3.4'] = (GiveTime);


dbConn.close();


Please help! Thanks.


Here is the entire error message:
Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransforme rException:
CHANNEL: Order plus RGV
CONNECTOR: RGV
SCRIPT SOURCE: TRANSFORMER
SOURCE CODE:
53: FreqID = msg['RXE']['RXE.1']['RXE.1.2']['RXE.1.2.1'].toString();
54: var expression = "SELECT HOURS from FREQ_TIMES WHERE FREQ_ID = '" + FreqID + "'";
55: var result = dbConn.executeCachedQuery(expression);
56:
57: result.first();
58: var GiveTime = result.getInt(1);
59: tmp['RXG']['RXG.3'][0]['RXG.3.4'] = (GiveTime);
60:
61:
62: dbConn.close();
LINE NUMBER: 58
DETAILS: Wrapped java.lang.ArrayIndexOutOfBoundsException: -1
at 67806f94-6b1b-4566-a835-1502e1347e07:58 (doTransform)
at 67806f94-6b1b-4566-a835-1502e1347e07:65 (doScript)
at 67806f94-6b1b-4566-a835-1502e1347e07:67
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.call(JavaScr iptFilterTransformer.java:134)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.call(JavaScr iptFilterTransformer.java:100)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker( Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.Vector.elementData(Unknown Source)
at java.util.Vector.get(Unknown Source)
at com.sun.rowset.CachedRowSetImpl.getCurrentRow(Unkn own Source)
at com.sun.rowset.CachedRowSetImpl.getInt(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:126)
at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:225)
at org.mozilla.javascript.Interpreter.interpretLoop(I nterpreter.java:1473)
at org.mozilla.javascript.Interpreter.interpret(Inter preter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(In terpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:3110)
at org.mozilla.javascript.InterpretedFunction.exec(In terpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.executeScript(JavaScriptTask.java:49)
at com.mirth.connect.server.transformers.JavaScriptFi lterTransformer$FilterTransformerTask.call(JavaScr iptFilterTransformer.java:123)
... 5 more

Last edited by rparkinson; 12-11-2013 at 06:27 AM. Reason: Update
Reply With Quote
Reply

Tags
java javascript, sql query

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:40 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation