Hi, How can i retrieve image from database (in java). i am using MySQL. i have created a table which contain a column of blob type and manualy i have stored one image. after retrieving i will display it in word document.
Actually i am retrieving data from database and generating a word file. on that word document i have to display one image. I have inserted that image manualy to the database. but i dont know how to retrieve that image. if you have any idea to solve this problem then please help me.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35254
7
posted
0
Do you know how to execute SELECT statements? If so, you can use the getBlob method to get the data from the ResultSet.
krishna dey
Greenhorn
Joined: Mar 11, 2008
Posts: 12
posted
0
now i can retrieve the image from database. As i told that i am generating a word document. so after retrieving that image i am converting blob type to byte[] and then to string.
however while i am generating the word domument the image is is not coming. so many characters are printing to that documents. how can i get that image.
Converting binary data like an image to a string will almost certainly corrupt the image data. Why would you do that? How are you inserting the image data into a Word document?
krishna dey
Greenhorn
Joined: Mar 11, 2008
Posts: 12
posted
0
Hi Ulf Dittmer,
Using this code i am retreivivg and converting the image to string then i am using this string for word generator code. is there any other way to write image to word document?
int len = 0; len = (int)(rslogo.getBlob("uftjobs_logo").length()); byte [] data = rslogo.getBlob("uftjobs_logo").getBytes(1,len); for (int ii = 0; ii < len; ii++) { byte c = data[ii]; logo = logo + (char)c; }