Private voidsavebinary (InputStream in, Long userId, String fieldName) {SQL SQL=NewSQL ("INSERT into EEAS_USER_ATTH (id,content,user_id,atth_name) VALUES (SEQ_EEAS_USER_ATTH. Nextval,?,?,?) "); Sql.addparameter (NewParameter (Datatype.blob, in)); Sql.addparameter (NewParameter (Datatype.long, userId)); Sql.addparameter (NewParameter (datatype.string, fieldName)); Service.execute (SQL); } Publicinputstream getbinary (String sql) {InputStream fis=NULL; Connection Conn=NULL; PreparedStatement pstmt=NULL; Try{conn=contextutil.getconnection (); // --PSTMT =conn.preparestatement (SQL); ResultSet RS=Pstmt.executequery (); if(Rs.next ()) {FIS= Rs.getbinarystream (1); } rs.close (); // --}Catch(Exception e) {e.printstacktrace (); } finally { if(Pstmt! =NULL) { Try{pstmt.close (); } Catch(SQLException e) {e.printstacktrace (); } } if(Conn! =NULL) { Try{conn.close (); } Catch(SQLException e) {e.printstacktrace (); } } } returnfis; }
The Oracle database holds the read binary file (the file stream that is uploaded exists in the database)