I have stored an image in data base (mySql).I have taken the field type as blob and storing the image in string format.I successfully reciving the blob The response what i am getting is com.mysql.jdbc.Blob@34b7cdfb .Please can any one tell me how to convert it back to image and show it using jquery.Thanks in advance
Asked
Active
Viewed 56 times
0
-
did you get a chance to search SO . I just now searched and found : http://stackoverflow.com/questions/14610011/reading-a-blob-from-mysql-with-java – Satya Apr 13 '16 at 03:57
-
You need to add the code you used to encode it etc for anyone to help. – Harry Apr 13 '16 at 03:57
-
2Possible duplicate of [Retrieve an Image stored as BLOB on a MYSQL DB](http://stackoverflow.com/questions/2150265/retrieve-an-image-stored-as-blob-on-a-mysql-db) – Johnny Willer Apr 13 '16 at 03:57
-
Just a friendly tip, you may want to read over this page: [The How-To-Ask Guide](https://stackoverflow.com/help/how-to-ask) so you can always be sure that your questions are easily answerable and as clear as possible. Be sure to include any efforts you've made to fix the problem you're having, and what happened when you attempted those fixes. Also don't forget to your show code and any error messages! – Matt C Apr 13 '16 at 04:14
-
Thanks for the quick response.This is the code i am using object.put("img",set.getBinaryStream("img")); And the response i am getting is java.io.ByteArrayInputStream@5168abd7.Now how can i convert this back to the actual image and show it.Thanks in advance. – Abhishek Apr 13 '16 at 05:02
1 Answers
0
I advice you not to save your image in the database with time it going to slow your DBMS

ghaziksibi
- 471
- 3
- 12
-
I got so many images to be saved how can i do this without using database.Please let if there is any other way. – Abhishek Apr 13 '16 at 05:00
-
you'll just create a folder in your project in which you'll upload your images and you save their path in the database – ghaziksibi Apr 13 '16 at 05:04
-
In that case the code size will become big.Does it going to effect the performance? And also if i want to add more images once the website goes live is there any way to add the images to that folder. – Abhishek Apr 13 '16 at 05:07
-
yes it is absolutely possible and do not worry about the performance and code size – ghaziksibi Apr 13 '16 at 05:11
-
That's cool.Can you please tell me how to add the images to that folder without uploading the code to live again and again. – Abhishek Apr 13 '16 at 05:19
-
-
-
I currently work in Symfony2 lol try this http://www.tutorialspoint.com/servlets/servlets-file-uploading.htm – ghaziksibi Apr 13 '16 at 05:55