web stats
Insert blob field in bytea - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2016, 11:47 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default Insert blob field in bytea

Hi, i'm have a value in blob of my chanel, but i need to insert into field bytea(postgres).

But mirth return error:

[2016-10-13 15:45:40,140] ERROR (com.mirth.connect.connectors.jdbc.DatabaseDispatc herScript:152): Error evaluating Database Writer (Database Writer "PixeonToWTT" on channel 830f27ed-e4fe-4414-8dac-1fddb42aa34e).
com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
IntegraWTT - EnvioCONNECTOR:
PixeonToWTTSOURCE CODE:
632:

//ps.setBinaryStream(6, new javax.sql.rowset.serial.SerialBlob(new java.lang.String(x64).getBytes()));








633:

634:

ps.executeUpdate();

635:




636:
}catch(exception){637:

throw exception638:
}639:
640:
finally {

641:

if (dbConn) {LINE NUMBER:
637DETAILS:
JavaException: org.postgresql.util.PSQLException: Large Objects may not be used in auto-commit mode.
at dde761fd-625b-4284-8833-2dd4525777ea:637 (doScript)
at dde761fd-625b-4284-8833-2dd4525777ea:668
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:527)
at com.mirth.connect.connectors.jdbc.DatabaseDispatch erScript$DatabaseDispatcherTask.doCall(DatabaseDis patcherScript.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
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)



This is my chanel:

var report = $('report')
byteReport = report.getBytes(1, report.length());

x64 = FileUtil.encode(byteReport);
x64 = x64.replaceAll( "\r\n", "");

var dbConn;
var ps;


try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection ($cfg('driverWTT'),$cfg('urlWTT'),$cfg('userWTT'), $cfg('passWTT'));


insertMessage = "INSERT INTO PIXEON_T_OBX (MESSAGEID, ACCESSIONNUMBER, REQUESTEDPROCEDUREID, PATIENTID, OBSERVATIONDATETIME, OBSERVATIONVALUE ) VALUES (?,?,?,?,?,?)";

ps = dbConn.getConnection().prepareStatement(insertMess age);
ps.setInt(1, $('ID'));
//ps.setString(2, direction);
ps.setString(2, $('ACCESSIONNUMBER'));
ps.setString(3, $('REQUESTEDPROCEDUREID'));
ps.setString(4, $('PATIENTID'));
ps.setString(5,$('OBSERVATIONDATETIME'));
ps.setBlob(6, new javax.sql.rowset.serial.SerialBlob(new java.lang.String(x64).getBytes()));

ps.executeUpdate();

}catch(exception){
throw exception
}

finally {
if (dbConn) {
dbConn.close();
}
}



Thank's,
Leandro
Reply With Quote
  #2  
Old 10-13-2016, 12:15 PM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

You can turn off auto-commit: https://docs.oracle.com/javase/7/doc...ommit(boolean)
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 10-14-2016, 10:39 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default

now, mirth return this msg error:

[2016-10-14 14:43:10,331] ERROR (com.mirth.connect.connectors.jdbc.DatabaseDispatc herScript:152): Error evaluating Database Writer (Database Writer "PixeonToWTT" on channel 830f27ed-e4fe-4414-8dac-1fddb42aa34e).
com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
IntegraWTT - EnvioCONNECTOR:
PixeonToWTTSOURCE CODE:
635: 636:

dbConn.commit();637:

638:




639:
}catch(exception){640:

throw exception641:
}642:
643:
finally {

644:

if (dbConn) {LINE NUMBER:
640DETAILS:
JavaException: org.postgresql.util.PSQLException: ERROR: column "observationvalue" is of type bytea but expression is of type bigint Hint: You will need to rewrite or cast the expression. Position: 165
at 6e4f9a51-2f7c-4b04-877a-cd1c2a192421:640 (doScript)
at 6e4f9a51-2f7c-4b04-877a-cd1c2a192421:671
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.executeScript(JavaScriptUtil.java:527)
at com.mirth.connect.connectors.jdbc.DatabaseDispatch erScript$DatabaseDispatcherTask.doCall(DatabaseDis patcherScript.java:120)
at com.mirth.connect.server.util.javascript.JavaScrip tTask.call(JavaScriptTask.java:113)
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)



how input blob field in bytea?

Thank's,
Leandro

Last edited by lgiuriollo; 10-14-2016 at 10:45 AM.
Reply With Quote
  #4  
Old 10-17-2016, 05:02 AM
lgiuriollo lgiuriollo is offline
Mirth Newb
 
Join Date: Sep 2016
Posts: 17
lgiuriollo is on a distinguished road
Default

up
Reply With Quote
  #5  
Old 10-17-2016, 07:09 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 835
siddharth is on a distinguished road
Default

Try changing this

ps.setBlob(6, new javax.sql.rowset.serial.SerialBlob(new java.lang.String(x64).getBytes()));

to use setBytes method.

void setBytes(int parameterIndex,
byte[] x)

byte[] x is the byte array which is bytea for postgresql
https://docs.oracle.com/javase/7/doc...es(int,%20byte[])
Reply With Quote
Reply

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 11:12 AM.


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