public void getSQLFromField ( PreparedStatement statement , int iType , int iParamColumn ) throws SQLException { if ( this . isNull ( ) ) statement . setNull ( iParamColumn , Types . BLOB ) ; else { Object data = this . getData ( ) ; ByteArrayOutputStream ostream = new ByteArrayOutputStream ( ) ; ObjectOutputStream p = null ; try { p = new ObjectOutputStream ( ostream ) ; p . writeObject ( data ) ; p . flush ( ) ; ostream . close ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; // Never } byte [ ] rgBytes = ostream . toByteArray ( ) ; InputStream iStream = new ByteArrayInputStream ( rgBytes ) ; try { statement . setBinaryStream ( iParamColumn , iStream , rgBytes . length ) ; } catch ( java . lang . ArrayIndexOutOfBoundsException ex ) { ex . printStackTrace ( ) ; } } }
Move the physical binary data to this SQL parameter row . This method uses the setBinaryStrem statement method .