d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Help Me Save Picture As Blob On My Db > Need To Make It A Serializable Not Fis
Add Reply New Topic New Poll
Member
Posts: 4,478
Joined: Feb 10 2010
Gold: 1,806.00
Apr 14 2013 01:10pm
I am stuck. This is the code so far. It does not work.

billede means Image

fis.setBillede(bille); needs to make it a Serializable not FileInputStream

Code
      public void savebillede()
      {
                   EntityManagerFactory  factory = Persistence.createEntityManagerFactory("Contact DB");
  EntityManager em = factory.createEntityManager();
  em.getTransaction().begin();
          Gtspiller fis = em.find(Gtspiller.class, 1);
  File image = new File("C:\\portrait\\monkey.gif");
  FileInputStream bille = null;
  bille = new FileInputStream(image);
 
  fis.setBillede(bille);
     em.getTransaction().commit();
  em.close();
      }


Its probably very simple. Think I have to Somehow convert the image to an byte[] first

Thanks
Member
Posts: 4,478
Joined: Feb 10 2010
Gold: 1,806.00
Apr 14 2013 02:06pm
Have figured it out myself-

my face is red. took me 3 hours to realize it was already a byte array
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll