• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Insert into MySQL DB an image from an http URL

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to insert an image from an URL, directly into the database.

The problem is that when I open the image in Workbench, after it's insertion, it doesn't get displayed. Can you tell me please, is it something wrong with this code? Except the OOP syntax.
The field for the image in the DB is Medium Blob.



 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you been able to get Workbench to display images which came from other sources, or which you put into the database in different ways? If so then it would be useful to compare what you did here with what you did which worked.
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Workbench will display the images from other databases. And a weird fact: if I click to open a field of text format, in the same table, it will open it; then, I click to open the image, it opens it, but in the "Image" tab, it displays nothing... though the Binary is displayed.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So... you have no evidence that Workbench knows how to display images which are stored in MySQL?

Have you considered modifying your code to use one of the databases which Workbench does know how to display images from?
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, It's just weird for me. It's 4 AM by my local time and I'm tired... can't go to bed because of this.

But, does the code seem correct?
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind, I solved it. Hooray.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would you like to tell us how? Others could learn from it.
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By solving I meant more like clarifying if the picture managed to be inserted in the DB. I checked if the picture was inserted, by querying the DB, retrieving the blob and storing it in a local file. Yes, the pictures were inserted, the entire time.

The question is: if I understood why Workbench didn't show the picture in the "Image" tab? Nope.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know anything about your Workbench, but it seems to me it would have to know that a set of bytes in a database column represented an image (and not, say, a Microsoft Word document or a serialized Java object). That's why I tried to suggest that you should look at how it worked with other databases. Maybe there's a configuration file somewhere where you tell it that column ABC contains JPG images? Maybe you have to use a particular column definition not supported in MySQL? Or you just used the wrong type of column? The possibilities are endless.
 
Robert Insanovation White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank's for the various ideas, it gave me an image for the future experiences.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic