jdk/src/share/classes/java/sql/Blob.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 18564 f9db68ff2cbb
child 23590 ffd8b0b70511
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
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
18564
f9db68ff2cbb 8017471: Fix JDBC -Xdoclint public errors
lancea
parents: 5506
diff changeset
    32
 * the Java™ programming
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * language of an SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <code>BLOB</code> value.  An SQL <code>BLOB</code> is a built-in type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * that stores a Binary Large Object as a column value in a row of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * a database table. By default drivers implement <code>Blob</code> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * an SQL <code>locator(BLOB)</code>, which means that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <code>Blob</code> object contains a logical pointer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * SQL <code>BLOB</code> data rather than the data itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A <code>Blob</code> object is valid for the duration of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * transaction in which is was created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <P>Methods in the interfaces {@link ResultSet},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * {@link CallableStatement}, and {@link PreparedStatement}, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <code>getBlob</code> and <code>setBlob</code> allow a programmer to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * access an SQL <code>BLOB</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * The <code>Blob</code> interface provides methods for getting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * length of an SQL <code>BLOB</code> (Binary Large Object) value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * for materializing a <code>BLOB</code> value on the client, and for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * determining the position of a pattern of bytes within a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <code>BLOB</code> value. In addition, this interface has methods for updating
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * a <code>BLOB</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * All methods on the <code>Blob</code> interface must be fully implemented if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * JDBC driver supports the data type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public interface Blob {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
   * Returns the number of bytes in the <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
   * designated by this <code>Blob</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
   * @return length of the <code>BLOB</code> in bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
   * @exception SQLException if there is an error accessing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
   * length of the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
   * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
   * this method
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
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
   * Retrieves all or part of the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
   * value that this <code>Blob</code> object represents, as an array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
   * bytes.  This <code>byte</code> array contains up to <code>length</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
   * consecutive bytes starting at position <code>pos</code>.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
   *        <code>BLOB</code> value to be extracted; the first byte is at
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
   * for length must be 0 or greater
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
   * @return a byte array containing up to <code>length</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
   *         consecutive bytes from the <code>BLOB</code> value designated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
   *         by this <code>Blob</code> object, starting with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
   *         byte at position <code>pos</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * @exception SQLException if there is an error accessing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   *            <code>BLOB</code> value; if pos is less than 1 or length is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   * less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
   * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
   * this method
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
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
   * Retrieves the <code>BLOB</code> value designated by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
   * <code>Blob</code> instance as a stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
   * @return a stream containing the <code>BLOB</code> data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
   * @exception SQLException if there is an error accessing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
   *            <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
   * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
   * this method
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
   * <code>pattern</code> begins within the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
   * value that this <code>Blob</code> object represents.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
   * search for <code>pattern</code> begins at position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
   * <code>start</code>.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
   * <code>BLOB</code> or if start is less than 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
   * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
   * this method
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
  /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
   * Retrieves the byte position in the <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
   * designated by this <code>Blob</code> object at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
   * <code>pattern</code> begins.  The search begins at position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
   * <code>start</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
   *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
   * @param pattern the <code>Blob</code> object designating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
   * the <code>BLOB</code> value for which to search
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
   * @param start the position in the <code>BLOB</code> value
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
   *            <code>BLOB</code> value or if start is less than 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
   * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
   * this method
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Writes the given array of bytes to the <code>BLOB</code> value that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * this <code>Blob</code> object represents, starting at position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <code>pos</code>, and returns the number of bytes written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The array of bytes will overwrite the existing bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * in the <code>Blob</code> object starting at the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * <code>pos</code>.  If the end of the <code>Blob</code> value is reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * while writing the array of bytes, then the length of the <code>Blob</code>
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * <b>Note:</b> If the value specified for <code>pos</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * is greater then the length+1 of the <code>BLOB</code> value then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * behavior is undefined. Some JDBC drivers may throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * <code>SQLException</code> while other drivers may support this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param pos the position in the <code>BLOB</code> object at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *        to start writing; the first position is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param bytes the array of bytes to be written to the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *        value that this <code>Blob</code> object represents
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *            <code>BLOB</code> value or if pos is less than 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * this method
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Writes all or part of the given <code>byte</code> array to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <code>BLOB</code> value that this <code>Blob</code> object represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * and returns the number of bytes written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Writing starts at position <code>pos</code> in the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * value; <code>len</code> bytes from the given byte array are written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * The array of bytes will overwrite the existing bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * in the <code>Blob</code> object starting at the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * <code>pos</code>.  If the end of the <code>Blob</code> value is reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * while writing the array of bytes, then the length of the <code>Blob</code>
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * <b>Note:</b> If the value specified for <code>pos</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * is greater then the length+1 of the <code>BLOB</code> value then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * behavior is undefined. Some JDBC drivers may throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * <code>SQLException</code> while other drivers may support this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @param pos the position in the <code>BLOB</code> object at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *        to start writing; the first position is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @param bytes the array of bytes to be written to this <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *        object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param offset the offset into the array <code>bytes</code> at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *        to start reading the bytes to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param len the number of bytes to be written to the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *        value from the array of bytes <code>bytes</code>
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *            <code>BLOB</code> value or if pos is less than 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * this method
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Retrieves a stream that can be used to write to the <code>BLOB</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * value that this <code>Blob</code> object represents.  The stream begins
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * at position <code>pos</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * The  bytes written to the stream will overwrite the existing bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * in the <code>Blob</code> object starting at the position
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <code>pos</code>.  If the end of the <code>Blob</code> value is reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * while writing to the stream, then the length of the <code>Blob</code>
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * <b>Note:</b> If the value specified for <code>pos</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * is greater then the length+1 of the <code>BLOB</code> value then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * behavior is undefined. Some JDBC drivers may throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * <code>SQLException</code> while other drivers may support this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @param pos the position in the <code>BLOB</code> value at which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *        to start writing; the first position is 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @return a <code>java.io.OutputStream</code> object to which data can
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *            <code>BLOB</code> value or if pos is less than 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * this method
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Truncates the <code>BLOB</code> value that this <code>Blob</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * object represents to be <code>len</code> bytes in length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * <b>Note:</b> If the value specified for <code>pos</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * is greater then the length+1 of the <code>BLOB</code> value then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * behavior is undefined. Some JDBC drivers may throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <code>SQLException</code> while other drivers may support this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @param len the length, in bytes, to which the <code>BLOB</code> value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     *        that this <code>Blob</code> object represents should be truncated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * @exception SQLException if there is an error accessing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *            <code>BLOB</code> value or if len is less than 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * this method
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * This method frees the <code>Blob</code> object and releases the resources that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * it holds. The object is invalid once the <code>free</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * method is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * After <code>free</code> has been called, any attempt to invoke a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * method other than <code>free</code> will result in a <code>SQLException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * being thrown.  If <code>free</code> is called multiple times, the subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * calls to <code>free</code> are treated as a no-op.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @throws SQLException if an error occurs releasing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * the Blob's resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    void free() throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * starting  with the byte specified by pos, which is length bytes in length.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param pos the offset to the first byte of the partial value to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *  The first byte in the <code>Blob</code> is at position 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param length the length in bytes of the partial value to be retrieved
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * @return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @throws SQLException if pos is less than 1 or if pos is greater than the number of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * in the <code>Blob</code> or if pos + length is greater than the number of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * in the <code>Blob</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    InputStream getBinaryStream(long pos, long length) throws SQLException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
}