src/java.sql/share/classes/java/sql/Blob.java
author lkorinth
Wed, 13 Nov 2019 11:37:29 +0100
changeset 59053 ba6c248cae19
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector Reviewed-by: kbarrett, tschatzl, erikj, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 5506
diff changeset
     2
 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.sql;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The representation (mapping) in
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    32
 * the Java™ programming language of an SQL
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    33
 * {@code BLOB} value.  An SQL {@code BLOB} is a built-in type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * that stores a Binary Large Object as a column value in a row of
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    35
 * a database table. By default drivers implement {@code Blob} using
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    36
 * an SQL {@code locator(BLOB)}, which means that a
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    37
 * {@code Blob} object contains a logical pointer to the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    38
 * SQL {@code BLOB} data rather than the data itself.
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    39
 * A {@code Blob} object is valid for the duration of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * transaction in which is was created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <P>Methods in the interfaces {@link ResultSet},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * {@link CallableStatement}, and {@link PreparedStatement}, such as
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    44
 * {@code getBlob} and {@code setBlob} allow a programmer to
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    45
 * access an SQL {@code BLOB} value.
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    46
 * The {@code Blob} interface provides methods for getting the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    47
 * length of an SQL {@code BLOB} (Binary Large Object) value,
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    48
 * for materializing a {@code BLOB} value on the client, and for
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * determining the position of a pattern of bytes within a
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    50
 * {@code BLOB} value. In addition, this interface has methods for updating
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    51
 * a {@code BLOB} value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    53
 * All methods on the {@code Blob} interface must be fully implemented if the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * JDBC driver supports the data type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public interface Blob {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    62
   * Returns the number of bytes in the {@code BLOB} value
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    63
   * designated by this {@code Blob} object.
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    64
   *
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    65
   * @return length of the {@code BLOB} in bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
   * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    67
   *            length of the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    68
   * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    69
   *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
  long length() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
  /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    75
   * Retrieves all or part of the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    76
   * value that this {@code Blob} object represents, as an array of
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    77
   * bytes.  This {@code byte} array contains up to {@code length}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    78
   * consecutive bytes starting at position {@code pos}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
   * @param pos the ordinal position of the first byte in the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    81
   *        {@code BLOB} value to be extracted; the first byte is at
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
   *        position 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
   * @param length the number of consecutive bytes to be copied; the value
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    84
   *        for length must be 0 or greater
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    85
   * @return a byte array containing up to {@code length}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    86
   *         consecutive bytes from the {@code BLOB} value designated
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    87
   *         by this {@code Blob} object, starting with the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    88
   *         byte at position {@code pos}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    90
   *            {@code BLOB} value; if pos is less than 1 or length is
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    91
   *            less than 0
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    92
   * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
    93
   *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
   * @see #setBytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
  byte[] getBytes(long pos, int length) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
  /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   100
   * Retrieves the {@code BLOB} value designated by this
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   101
   * {@code Blob} instance as a stream.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   103
   * @return a stream containing the {@code BLOB} data
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
   * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   105
   *            {@code BLOB} value
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   106
   * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   107
   *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
   * @see #setBinaryStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
  java.io.InputStream getBinaryStream () throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
   * Retrieves the byte position at which the specified byte array
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   115
   * {@code pattern} begins within the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   116
   * value that this {@code Blob} object represents.
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   117
   * The search for {@code pattern} begins at position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   118
   * {@code start}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
   * @param pattern the byte array for which to search
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
   * @param start the position at which to begin searching; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
   *        first position is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
   * @return the position at which the pattern appears, else -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
   * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   125
   *            {@code BLOB} or if start is less than 1
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   126
   * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   127
   *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
  long position(byte pattern[], long start) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
  /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   133
   * Retrieves the byte position in the {@code BLOB} value
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   134
   * designated by this {@code Blob} object at which
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   135
   * {@code pattern} begins.  The search begins at position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   136
   * {@code start}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
   *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   138
   * @param pattern the {@code Blob} object designating
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   139
   *        the {@code BLOB} value for which to search
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   140
   * @param start the position in the {@code BLOB} value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
   *        at which to begin searching; the first position is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
   * @return the position at which the pattern begins, else -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
   * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   144
   *            {@code BLOB} value or if start is less than 1
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   145
   * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   146
   *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
   * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
  long position(Blob pattern, long start) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    // -------------------------- JDBC 3.0 -----------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   154
     * Writes the given array of bytes to the {@code BLOB} value that
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   155
     * this {@code Blob} object represents, starting at position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   156
     * {@code pos}, and returns the number of bytes written.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The array of bytes will overwrite the existing bytes
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   158
     * in the {@code Blob} object starting at the position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   159
     * {@code pos}.  If the end of the {@code Blob} value is reached
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   160
     * while writing the array of bytes, then the length of the {@code Blob}
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18564
diff changeset
   161
     * value will be increased to accommodate the extra bytes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   163
     * <b>Note:</b> If the value specified for {@code pos}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   164
     * is greater than the length+1 of the {@code BLOB} value then the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   165
     * behavior is undefined. Some JDBC drivers may throw an
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   166
     * {@code SQLException} while other drivers may support this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   169
     * @param pos the position in the {@code BLOB} object at which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *        to start writing; the first position is 1
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   171
     * @param bytes the array of bytes to be written to the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   172
     *        value that this {@code Blob} object represents
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @return the number of bytes written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   175
     *            {@code BLOB} value or if pos is less than 1
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   176
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   177
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @see #getBytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    int setBytes(long pos, byte[] bytes) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   184
     * Writes all or part of the given {@code byte} array to the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   185
     * {@code BLOB} value that this {@code Blob} object represents
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * and returns the number of bytes written.
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   187
     * Writing starts at position {@code pos} in the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   188
     * value; {@code len} bytes from the given byte array are written.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * The array of bytes will overwrite the existing bytes
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   190
     * in the {@code Blob} object starting at the position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   191
     * {@code pos}.  If the end of the {@code Blob} value is reached
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   192
     * while writing the array of bytes, then the length of the {@code Blob}
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18564
diff changeset
   193
     * value will be increased to accommodate the extra bytes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   195
     * <b>Note:</b> If the value specified for {@code pos}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   196
     * is greater than the length+1 of the {@code BLOB} value then the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   197
     * behavior is undefined. Some JDBC drivers may throw an
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   198
     * {@code SQLException} while other drivers may support this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   201
     * @param pos the position in the {@code BLOB} object at which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *        to start writing; the first position is 1
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   203
     * @param bytes the array of bytes to be written to this {@code BLOB}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *        object
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   205
     * @param offset the offset into the array {@code bytes} at which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *        to start reading the bytes to be set
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   207
     * @param len the number of bytes to be written to the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   208
     *        value from the array of bytes {@code bytes}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @return the number of bytes written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   211
     *            {@code BLOB} value or if pos is less than 1
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   212
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   213
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * @see #getBytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   220
     * Retrieves a stream that can be used to write to the {@code BLOB}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   221
     * value that this {@code Blob} object represents.  The stream begins
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   222
     * at position {@code pos}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * The  bytes written to the stream will overwrite the existing bytes
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   224
     * in the {@code Blob} object starting at the position
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   225
     * {@code pos}.  If the end of the {@code Blob} value is reached
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   226
     * while writing to the stream, then the length of the {@code Blob}
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18564
diff changeset
   227
     * value will be increased to accommodate the extra bytes.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   229
     * <b>Note:</b> If the value specified for {@code pos}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   230
     * is greater than the length+1 of the {@code BLOB} value then the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   231
     * behavior is undefined. Some JDBC drivers may throw an
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   232
     * {@code SQLException} while other drivers may support this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   235
     * @param pos the position in the {@code BLOB} value at which
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *        to start writing; the first position is 1
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   237
     * @return a {@code java.io.OutputStream} object to which data can
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *         be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   240
     *            {@code BLOB} value or if pos is less than 1
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   241
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   242
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * @see #getBinaryStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    java.io.OutputStream setBinaryStream(long pos) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   249
     * Truncates the {@code BLOB} value that this {@code Blob}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   250
     * object represents to be {@code len} bytes in length.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   252
     * <b>Note:</b> If the value specified for {@code pos}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   253
     * is greater than the length+1 of the {@code BLOB} value then the
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   254
     * behavior is undefined. Some JDBC drivers may throw an
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   255
     * {@code SQLException} while other drivers may support this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   258
     * @param len the length, in bytes, to which the {@code BLOB} value
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   259
     *        that this {@code Blob} object represents should be truncated
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @exception SQLException if there is an error accessing the
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   261
     *            {@code BLOB} value or if len is less than 0
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   262
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   263
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    void truncate(long len) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   269
     * This method frees the {@code Blob} object and releases the resources that
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   270
     * it holds. The object is invalid once the {@code free}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * method is called.
23590
ffd8b0b70511 8038493: Tidy warnings cleanup for java.sql
yan
parents: 21278
diff changeset
   272
     * <p>
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   273
     * After {@code free} has been called, any attempt to invoke a
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   274
     * method other than {@code free} will result in an {@code SQLException}
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   275
     * being thrown.  If {@code free} is called multiple times, the subsequent
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   276
     * calls to {@code free} are treated as a no-op.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @throws SQLException if an error occurs releasing
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   279
     *         the Blob's resources
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   280
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   281
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    void free() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   287
     * Returns an {@code InputStream} object that contains
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   288
     * a partial {@code Blob} value, starting with the byte
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   289
     * specified by pos, which is length bytes in length.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   291
     * @param pos the offset to the first byte of the partial value to be
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   292
     *        retrieved. The first byte in the {@code Blob} is at position 1.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param length the length in bytes of the partial value to be retrieved
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   294
     * @return {@code InputStream} through which
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   295
     *         the partial {@code Blob} value can be read.
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   296
     * @throws SQLException if pos is less than 1 or if pos is greater
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   297
     *         than the number of bytes in the {@code Blob} or if
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   298
     *         pos + length is greater than the number of bytes
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   299
     *         in the {@code Blob}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *
30797
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   301
     * @exception SQLFeatureNotSupportedException if the JDBC driver
9cf3d0361db4 8040147: minor cleanup for docs
avstepan
parents: 25859
diff changeset
   302
     *            does not support this method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    InputStream getBinaryStream(long pos, long length) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
}