I want to save image files to database by java, file chooser.
My db name is "gallery_images", table name is "image_table", and the columns are "image id(int)"autoincrement, "image(longblob)", and "username(varchar2(45))".
I can add images to my mysql database by workbench to a longblob (right click on longblob cell, "Load Value From File"), and when Ii execute it, it gives me this code:
INSERT INTO `image_table`.`gallery_images` (`image`, `username`) VALUES (?, 'viktor');
The "?" should be the image, so I didn't learn much by this code. When I read a File by java, how could I insert it into my table (with jdbc)?
And when I done with this, I want to query every data from that table:
SELECT * FROM image_table;
I want to save the images from the DB to a List:
private List<Image> images;
I think, I should use the "while(resultset.next()", but how should I get the image from the resultset in the while? Can any one help me with this? Thank you!