Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to retrieve byteArray/blob from Data base?

Hi All,
Using Talend job , I need to retrieve images from data base to local system. Images are stored in DB as byte array.
Could any 1 please guide me on this.

Thanks In Advance
Chaya
Labels (2)
15 Replies
Anonymous
Not applicable
Author

No Luck Pedro, 0683p000009MPcz.png
I tried uploading new image to DB (even different formats) & retried to download but no luck. Issue remains the same.
Should I mail You the complete job or upload the screen shots ?
Anonymous
Not applicable
Author

I think you can read it in as an object type and map this to an object typ output in a tMap. No coding required.

Hi janhess,
Thanks.. Could You Please elaborate ur approach, though i read it like an object, how can I write that object with out coding... please explain
janhess
Creator II
Creator II

Sorry just map a byte array input to a byte array output.
Anonymous
Not applicable
Author

Thanks janhess ..
Still, I continue to face the same issue, Please fine the attachment. In which I have uploaded the image which I m trying to read from DB and also the job flow.
Thanks for ur time..
Anonymous
Not applicable
Author

Hi Team,
Some where I m going wrong, either reading or may be while uploading to DB itself.
So, please look in to the attachments for the way I am uploading my image to DB.
& I have already posted the way I m reading it. So, please let me know in case if i m wrong.
Routine Code:
public static byte[] ByteArrayFromFile(String filepath) {
try
{
java.io.File file=new java.io.File(filepath);
java.io.FileInputStream fis = new java.io.FileInputStream(file);
int fileLength = (int) file.length();
byte[] incoming_file_data = new byte;
fis.read(incoming_file_data, 0, fileLength );
fis.close();
return incoming_file_data;
}
catch(Exception err)
{
err.printStackTrace();
return null;
}
}

Please help me on this.,
Thanks
janhess
Creator II
Creator II

You didn't specify a field length in your output. Should be the same as input.
I use this to import images to a database.
The rule in the tMap is ImageUtil.getByte(row6.abs_path) where abs_path is the path to the image file
package routines;
import java.io.FileInputStream;
import java.io.File;
import java.io.FileNotFoundException;
public class ImageUtil {
public static byte[] getByte(String filepath) {
byte[] b=null;

try {
FileInputStream fis = new FileInputStream(filepath);
b=new byte;
fis.read(b);
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
}