Im using this code to get image from SQLITE


          String sql = "SELECT Photo FROM Pics WHERE InvoiceNumber=?";
          pst = conn.prepareStatement(sql);


              byte[]imagedata = rs.getBytes("Photo");
              format = new ImageIcon(imagedata);



      }catch(Exception e){
      JOptionPane.showMessageDialog(null, e);

private ImageIcon format = null;

String filename = null;

int s=0;
byte[] bill_image = null;

how to fix this?
I get no result

Hi altgen,

why you are storing images into DB.i think it is not a best practice.
instead of that store image path into DB and refer that path to the image which is in your page.

try this idea once

reply me incase if you have any doubts in the response

best of luck

Edited 1 Year Ago by ihelpyou: give clarity on this idea

actually, storing the images inside the database is a very good idea as it prevents your data from getting corrupted if the location on the filesystem where the images exist changes.
Of course there's some added cost in time needed for retrieval and possibly higher storage requirements, but for real world applications those are of miniscule concern as compared to data integrity.

Hi Ihelpyou,
sorry to tell you but you gave me a wrong name :) but no problem

and as jwenting says if change the file location, it wont find it .

but thank you for both of your suggestions, but I found a good way to make the pic system.

This article has been dead for over six months. Start a new discussion instead.