Path: blob/master/src/java.sql/share/classes/java/sql/RowId.java
41153 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.sql;2627/**28*29* The representation (mapping) in the Java programming language of an SQL ROWID30* value. An SQL ROWID is a built-in type, a value of which can be thought of as31* an address for its identified row in a database table. Whether that address32* is logical or, in any respects, physical is determined by its originating data33* source.34* <p>35* Methods in the interfaces {@code ResultSet}, {@code CallableStatement},36* and {@code PreparedStatement}, such as {@code getRowId} and {@code setRowId}37* allow a programmer to access a SQL {@code ROWID} value. The {@code RowId}38* interface provides a method39* for representing the value of the {@code ROWID} as a byte array or as a40* {@code String}.41* <p>42* The method {@code getRowIdLifetime} in the interface {@code DatabaseMetaData},43* can be used44* to determine if a {@code RowId} object remains valid for the duration of the transaction in45* which the {@code RowId} was created, the duration of the session in which46* the {@code RowId} was created,47* or, effectively, for as long as its identified row is not deleted. In addition48* to specifying the duration of its valid lifetime outside its originating data49* source, {@code getRowIdLifetime} specifies the duration of a {@code ROWID}50* value's valid lifetime51* within its originating data source. In this, it differs from a large object,52* because there is no limit on the valid lifetime of a large object within its53* originating data source.54* <p>55* All methods on the {@code RowId} interface must be fully implemented if the56* JDBC driver supports the data type.57*58* @see java.sql.DatabaseMetaData59* @since 1.660*/6162public interface RowId {63/**64* Compares this {@code RowId} to the specified object. The result is65* {@code true} if and only if the argument is not null and is a RowId66* object that represents the same ROWID as this object.67* <p>68* It is important69* to consider both the origin and the valid lifetime of a {@code RowId}70* when comparing it to another {@code RowId}. If both are valid, and71* both are from the same table on the same data source, then if they are equal72* they identify73* the same row; if one or more is no longer guaranteed to be valid, or if74* they originate from different data sources, or different tables on the75* same data source, they may be equal but still76* not identify the same row.77*78* @param obj the {@code Object} to compare this {@code RowId} object79* against.80* @return true if the {@code RowId}s are equal; false otherwise81* @since 1.682*/83boolean equals(Object obj);8485/**86* Returns an array of bytes representing the value of the SQL {@code ROWID}87* designated by this {@code java.sql.RowId} object.88*89* @return an array of bytes, whose length is determined by the driver supplying90* the connection, representing the value of the ROWID designated by this91* java.sql.RowId object.92*/93byte[] getBytes();9495/**96* Returns a String representing the value of the SQL ROWID designated by this97* {@code java.sql.RowId} object.98* <p>99*Like {@code java.sql.Date.toString()}100* returns the contents of its DATE as the {@code String} "2004-03-17"101* rather than as DATE literal in SQL (which would have been the {@code String}102* DATE "2004-03-17"), toString()103* returns the contents of its ROWID in a form specific to the driver supplying104* the connection, and possibly not as a {@code ROWID} literal.105*106* @return a String whose format is determined by the driver supplying the107* connection, representing the value of the {@code ROWID} designated108* by this {@code java.sql.RowId} object.109*/110String toString();111112/**113* Returns a hash code value of this {@code RowId} object.114*115* @return a hash code for the {@code RowId}116*/117int hashCode();118119}120121122