Class SqlBinaryValue

java.lang.Object
org.springframework.jdbc.core.support.SqlBinaryValue
All Implemented Interfaces:
SqlTypeValue

public class SqlBinaryValue extends Object implements SqlTypeValue
Object to represent a binary parameter value for a SQL statement, e.g. a binary stream for a BLOB or a LONGVARBINARY or PostgreSQL BYTEA column.

Designed for use with JdbcTemplate as well as JdbcClient, to be passed in as a parameter value wrapping the target content value. Can be combined with SqlParameterValue for specifying a SQL type, e.g. new SqlParameterValue(Types.BLOB, new SqlBinaryValue(myContent)). With most database drivers, the type hint is not actually necessary.

Since:
6.1.4
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • SqlBinaryValue

      public SqlBinaryValue(byte[] bytes)
      Create a new SqlBinaryValue for the given content.
      Parameters:
      bytes - the content as a byte array
    • SqlBinaryValue

      public SqlBinaryValue(InputStream stream, long length)
      Create a new SqlBinaryValue for the given content.
      Parameters:
      stream - the content stream
      length - the length of the content
    • SqlBinaryValue

      public SqlBinaryValue(InputStreamSource resource, long length)
      Create a new SqlBinaryValue for the given content.

      Consider specifying a Resource with content length support when available: SqlBinaryValue(Resource).

      Parameters:
      resource - the resource to obtain a content stream from
      length - the length of the content
    • SqlBinaryValue

      public SqlBinaryValue(Resource resource)
      Create a new SqlBinaryValue for the given content.

      The length will get derived from Resource.contentLength().

      Parameters:
      resource - the resource to obtain a content stream from
  • Method Details