Source Code Cross Referenced for Blob.java in  » 6.0-JDK-Core » sql » java » sql » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » sql » java.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.sql;
027
028        import java.io.InputStream;
029
030        /**
031         * The representation (mapping) in
032         * the Java<sup><font size=-2>TM</font></sup> programming
033         * language of an SQL 
034         * <code>BLOB</code> value.  An SQL <code>BLOB</code> is a built-in type 
035         * that stores a Binary Large Object as a column value in a row of 
036         * a database table. By default drivers implement <code>Blob</code> using
037         * an SQL <code>locator(BLOB)</code>, which means that a
038         * <code>Blob</code> object contains a logical pointer to the
039         * SQL <code>BLOB</code> data rather than the data itself.
040         * A <code>Blob</code> object is valid for the duration of the
041         * transaction in which is was created.
042         * 
043         * <P>Methods in the interfaces {@link ResultSet}, 
044         * {@link CallableStatement}, and {@link PreparedStatement}, such as
045         * <code>getBlob</code> and <code>setBlob</code> allow a programmer to 
046         * access an SQL <code>BLOB</code> value.
047         * The <code>Blob</code> interface provides methods for getting the
048         * length of an SQL <code>BLOB</code> (Binary Large Object) value,
049         * for materializing a <code>BLOB</code> value on the client, and for
050         * determining the position of a pattern of bytes within a 
051         * <code>BLOB</code> value. In addition, this interface has methods for updating
052         * a <code>BLOB</code> value.
053         * <p>
054         * All methods on the <code>Blob</code> interface must be fully implemented if the 
055         * JDBC driver supports the data type.
056         *
057         * @since 1.2
058         */
059
060        public interface Blob {
061
062            /**
063             * Returns the number of bytes in the <code>BLOB</code> value
064             * designated by this <code>Blob</code> object.
065             * @return length of the <code>BLOB</code> in bytes
066             * @exception SQLException if there is an error accessing the
067             * length of the <code>BLOB</code>
068             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
069             * this method
070             * @since 1.2
071             */
072            long length() throws SQLException;
073
074            /**
075             * Retrieves all or part of the <code>BLOB</code>
076             * value that this <code>Blob</code> object represents, as an array of
077             * bytes.  This <code>byte</code> array contains up to <code>length</code> 
078             * consecutive bytes starting at position <code>pos</code>.
079             *
080             * @param pos the ordinal position of the first byte in the 
081             *        <code>BLOB</code> value to be extracted; the first byte is at
082             *        position 1
083             * @param length the number of consecutive bytes to be copied; the value 
084             * for length must be 0 or greater
085             * @return a byte array containing up to <code>length</code> 
086             *         consecutive bytes from the <code>BLOB</code> value designated
087             *         by this <code>Blob</code> object, starting with the
088             *         byte at position <code>pos</code>
089             * @exception SQLException if there is an error accessing the
090             *            <code>BLOB</code> value; if pos is less than 1 or length is
091             * less than 0
092             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
093             * this method
094             * @see #setBytes
095             * @since 1.2
096             */
097            byte[] getBytes(long pos, int length) throws SQLException;
098
099            /**
100             * Retrieves the <code>BLOB</code> value designated by this
101             * <code>Blob</code> instance as a stream.
102             *
103             * @return a stream containing the <code>BLOB</code> data
104             * @exception SQLException if there is an error accessing the
105             *            <code>BLOB</code> value
106             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
107             * this method
108             * @see #setBinaryStream
109             * @since 1.2
110             */
111            java.io.InputStream getBinaryStream() throws SQLException;
112
113            /** 
114             * Retrieves the byte position at which the specified byte array
115             * <code>pattern</code> begins within the <code>BLOB</code>
116             * value that this <code>Blob</code> object represents.  The
117             * search for <code>pattern</code> begins at position
118             * <code>start</code>.  
119             *
120             * @param pattern the byte array for which to search
121             * @param start the position at which to begin searching; the
122             *        first position is 1
123             * @return the position at which the pattern appears, else -1
124             * @exception SQLException if there is an error accessing the 
125             * <code>BLOB</code> or if start is less than 1
126             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
127             * this method
128             * @since 1.2
129             */
130            long position(byte pattern[], long start) throws SQLException;
131
132            /** 
133             * Retrieves the byte position in the <code>BLOB</code> value
134             * designated by this <code>Blob</code> object at which 
135             * <code>pattern</code> begins.  The search begins at position
136             * <code>start</code>.
137             *
138             * @param pattern the <code>Blob</code> object designating
139             * the <code>BLOB</code> value for which to search
140             * @param start the position in the <code>BLOB</code> value
141             *        at which to begin searching; the first position is 1
142             * @return the position at which the pattern begins, else -1
143             * @exception SQLException if there is an error accessing the
144             *            <code>BLOB</code> value or if start is less than 1
145             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
146             * this method
147             * @since 1.2
148             */
149            long position(Blob pattern, long start) throws SQLException;
150
151            // -------------------------- JDBC 3.0 -----------------------------------
152
153            /**
154             * Writes the given array of bytes to the <code>BLOB</code> value that
155             * this <code>Blob</code> object represents, starting at position 
156             * <code>pos</code>, and returns the number of bytes written.
157             * The array of bytes will overwrite the existing bytes 
158             * in the <code>Blob</code> object starting at the position 
159             * <code>pos</code>.  If the end of the <code>Blob</code> value is reached 
160             * while writing the array of bytes, then the length of the <code>Blob</code> 
161             * value will be increased to accomodate the extra bytes.
162             * <p>
163             * <b>Note:</b> If the value specified for <code>pos</code>
164             * is greater then the length+1 of the <code>BLOB</code> value then the 
165             * behavior is undefined. Some JDBC drivers may throw a 
166             * <code>SQLException</code> while other drivers may support this 
167             * operation.
168             *
169             * @param pos the position in the <code>BLOB</code> object at which
170             *        to start writing; the first position is 1
171             * @param bytes the array of bytes to be written to the <code>BLOB</code>
172             *        value that this <code>Blob</code> object represents
173             * @return the number of bytes written
174             * @exception SQLException if there is an error accessing the
175             *            <code>BLOB</code> value or if pos is less than 1
176             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
177             * this method
178             * @see #getBytes
179             * @since 1.4
180             */
181            int setBytes(long pos, byte[] bytes) throws SQLException;
182
183            /**
184             * Writes all or part of the given <code>byte</code> array to the
185             * <code>BLOB</code> value that this <code>Blob</code> object represents
186             * and returns the number of bytes written.
187             * Writing starts at position <code>pos</code> in the <code>BLOB</code>
188             * value; <code>len</code> bytes from the given byte array are written.
189             * The array of bytes will overwrite the existing bytes 
190             * in the <code>Blob</code> object starting at the position 
191             * <code>pos</code>.  If the end of the <code>Blob</code> value is reached 
192             * while writing the array of bytes, then the length of the <code>Blob</code> 
193             * value will be increased to accomodate the extra bytes.
194             * <p>
195             * <b>Note:</b> If the value specified for <code>pos</code>
196             * is greater then the length+1 of the <code>BLOB</code> value then the 
197             * behavior is undefined. Some JDBC drivers may throw a 
198             * <code>SQLException</code> while other drivers may support this 
199             * operation.
200             *
201             * @param pos the position in the <code>BLOB</code> object at which
202             *        to start writing; the first position is 1
203             * @param bytes the array of bytes to be written to this <code>BLOB</code>
204             *        object
205             * @param offset the offset into the array <code>bytes</code> at which
206             *        to start reading the bytes to be set
207             * @param len the number of bytes to be written to the <code>BLOB</code>
208             *        value from the array of bytes <code>bytes</code>
209             * @return the number of bytes written
210             * @exception SQLException if there is an error accessing the
211             *            <code>BLOB</code> value or if pos is less than 1
212             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
213             * this method
214             * @see #getBytes
215             * @since 1.4
216             */
217            int setBytes(long pos, byte[] bytes, int offset, int len)
218                    throws SQLException;
219
220            /**
221             * Retrieves a stream that can be used to write to the <code>BLOB</code> 
222             * value that this <code>Blob</code> object represents.  The stream begins
223             * at position <code>pos</code>.
224             * The  bytes written to the stream will overwrite the existing bytes 
225             * in the <code>Blob</code> object starting at the position 
226             * <code>pos</code>.  If the end of the <code>Blob</code> value is reached 
227             * while writing to the stream, then the length of the <code>Blob</code> 
228             * value will be increased to accomodate the extra bytes.
229             * <p>
230             * <b>Note:</b> If the value specified for <code>pos</code>
231             * is greater then the length+1 of the <code>BLOB</code> value then the 
232             * behavior is undefined. Some JDBC drivers may throw a 
233             * <code>SQLException</code> while other drivers may support this 
234             * operation.
235             *
236             * @param pos the position in the <code>BLOB</code> value at which
237             *        to start writing; the first position is 1
238             * @return a <code>java.io.OutputStream</code> object to which data can 
239             *         be written
240             * @exception SQLException if there is an error accessing the
241             *            <code>BLOB</code> value or if pos is less than 1
242             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
243             * this method
244             * @see #getBinaryStream
245             * @since 1.4
246             */
247            java.io.OutputStream setBinaryStream(long pos) throws SQLException;
248
249            /**
250             * Truncates the <code>BLOB</code> value that this <code>Blob</code>
251             * object represents to be <code>len</code> bytes in length.
252             * <p>
253             * <b>Note:</b> If the value specified for <code>pos</code>
254             * is greater then the length+1 of the <code>BLOB</code> value then the 
255             * behavior is undefined. Some JDBC drivers may throw a 
256             * <code>SQLException</code> while other drivers may support this 
257             * operation.
258             *
259             * @param len the length, in bytes, to which the <code>BLOB</code> value
260             *        that this <code>Blob</code> object represents should be truncated
261             * @exception SQLException if there is an error accessing the
262             *            <code>BLOB</code> value or if len is less than 0
263             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
264             * this method
265             * @since 1.4
266             */
267            void truncate(long len) throws SQLException;
268
269            /**
270             * This method frees the <code>Blob</code> object and releases the resources that 
271             * it holds. The object is invalid once the <code>free</code>
272             * method is called.
273             *<p>
274             * After <code>free</code> has been called, any attempt to invoke a
275             * method other than <code>free</code> will result in a <code>SQLException</code> 
276             * being thrown.  If <code>free</code> is called multiple times, the subsequent
277             * calls to <code>free</code> are treated as a no-op.
278             *<p>
279             * 
280             * @throws SQLException if an error occurs releasing
281             * the Blob's resources
282             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
283             * this method
284             * @since 1.6
285             */
286            void free() throws SQLException;
287
288            /**
289             * Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value, 
290             * starting  with the byte specified by pos, which is length bytes in length.
291             *
292             * @param pos the offset to the first byte of the partial value to be retrieved.
293             *  The first byte in the <code>Blob</code> is at position 1
294             * @param length the length in bytes of the partial value to be retrieved
295             * @return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
296             * @throws SQLException if pos is less than 1 or if pos is greater than the number of bytes
297             * in the <code>Blob</code> or if pos + length is greater than the number of bytes 
298             * in the <code>Blob</code>
299             *
300             * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
301             * this method
302             * @since 1.6
303             */
304            InputStream getBinaryStream(long pos, long length)
305                    throws SQLException;
306        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.