import java.sql.Blob; import javax.sql.rowset.serial.SerialBlob; byte[] byteArray = .....; Blob blob = new SerialBlob(byteArray);
/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (buf == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialClob instance once free() has been called."); } }
/** * Retrieves the next attribute in this <code>SQLInputImpl</code> object as * a <code>java.sql.Timestamp</code> object. * * @return the attribute; if the value is <code>SQL NULL</code>, return * <code>null</code> * @throws SQLException if the read position is located at an invalid * position; or if there are no further values in the stream. */ public java.sql.Timestamp readTimestamp() throws SQLException { return (java.sql.Timestamp)getNextAttribute(); }
@Override public Clob createSerial(Clob clob) throws SQLException { return new SerialClob(clob); } }
@Override public Array createSerial(Array array) throws SQLException { return new SerialArray(array); } }
@Override public Ref createSerial(Ref ref) throws SQLException { return new SerialRef(ref); } }
/** * String 2 blob blob. * * @param str the str * @return the blob * @throws SQLException the sql exception */ public static Blob string2blob(String str) throws SQLException { if (str == null) { return null; } return new SerialBlob(str.getBytes()); }
/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (elements == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialArray instance once free() has been called."); } }
@Override public Blob toDatabaseType(byte[] value) { if (value == null) { return null; } try { return new SerialBlob(value); } catch (SQLException e) { throw new RuntimeException(e); } }
/** * Check to see if this object had previously had its {@code free} method * called * * @throws SerialException */ private void isValid() throws SerialException { if (buf == null) { throw new SerialException("Error: You cannot call a method on a " + "SerialBlob instance once free() has been called."); } }
@Override public Blob read(ResultSet results, int column) throws SQLException { byte[] value = results.getBytes(column); return results.wasNull() ? null : new SerialBlob(value); }
@Override public Reader getCharacterStream() throws SerialException { throw new SerialException(); } };
/** * String 2 blob blob. * * @param str the str * @return the blob */ public static Blob string2blob(String str) { if (str == null) { return null; } try { return new SerialBlob(str.getBytes()); } catch (Exception e) { throw new ShouldNeverHappenException(e); } }
@Override public Blob toDatabaseType(BigInteger value) { if (value == null) return null; try { return new SerialBlob(value.toByteArray()); } catch (final SQLException ex) { throw new SpeedmentTypeMapperException( "Error mapping BigInteger to Blob.", ex); } }
Blob blob = new javax.sql.rowset.serial.SerialBlob(bytes);
@Override protected Blob getBlob(ResultSet resultSet, int columnIndex, Metadata m) throws SQLException { byte[] bytes = resultSet.getBytes(columnIndex); if (!resultSet.wasNull()) { return new SerialBlob(bytes); } return null; } }
/** * Returns a BLOB with given |data|. * * @param data the binary data * @return the created BLOB * @throws SQLException if fails to create a BLOB */ public Blob createBlob(final byte[] data) throws SQLException { return new javax.sql.rowset.serial.SerialBlob(data); } // end of createBlob
@Override public Blob createSerial(Blob blob) throws SQLException { return new SerialBlob(blob); } }
/** * Bulk constructor. */ public Blob(final byte[] bytes) throws SQLException { this.underlying = new SerialBlob(bytes); } // end of <init>
@POST @Path("/documents") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response loanDocuments(@FormDataParam("file") byte[] uploadedByteArray, @FormDataParam("file") FormDataContentDisposition detail) throws SQLException { java.sql.Blob blob = new javax.sql.rowset.serial.SerialBlob(uploadedByteArray); return Response.status(200).entity("FILE UPLOAD SUCCESS").build(); }