2017-07-26 50 views
0

如何在我的postgres中使用SQL插入file.exe?SQL在Postgres中插入file.exe

我的表 CREATE TABLE versaoatualizada( ID整數NOT NULL, 諾姆字符改變, arquivo的OID, 約束pk_arquivo PRIMARY KEY(ID) ); CREATE SEQUENCE seq_arquivo INCREMENT 1 START 1;

我的Java代碼

,但我發現了一些問題...... 我有一個exeption(演員BIGINTEGER到OID ..)

public File getFile(int id) { 
     File f = null; 
     try { 
      List<Object[]> lista = getEntityManager().createNativeQuery("sqlWorking").getResultList(); 
      Oid bytes; 
      Object[] a = lista.get(0); 
      bytes = (Oid) a[2];// oid field 
      f = new File("C:......."); 
      FileOutputStream fos = new FileOutputStream(f); 
      fos.write(bytes.getDER()); 
      fos.close(); 
      return f; 
     } catch (Exception ex) { 
      ex.printStackTrace(); 
     } 
     return null; 
    } 

回答