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 /**
029 * The mapping in the Java programming language of an SQL <code>REF</code>
030 * value, which is a reference to an SQL structured type value in the database.
031 * <P>
032 * SQL <code>REF</code> values are stored in a table that contains
033 * instances of a referenceable SQL structured type, and each <code>REF</code>
034 * value is a unique identifier for one instance in that table.
035 * An SQL <code>REF</code> value may be used in place of the
036 * SQL structured type it references, either as a column value in a
037 * table or an attribute value in a structured type.
038 * <P>
039 * Because an SQL <code>REF</code> value is a logical pointer to an
040 * SQL structured type, a <code>Ref</code> object is by default also a logical
041 * pointer. Thus, retrieving an SQL <code>REF</code> value as
042 * a <code>Ref</code> object does not materialize
043 * the attributes of the structured type on the client.
044 * <P>
045 * A <code>Ref</code> object can be stored in the database using the
046 * <code>PreparedStatement.setRef</code> method.
047 * <p>
048 * All methods on the <code>Ref</code> interface must be fully implemented if the
049 * JDBC driver supports the data type.
050 *
051 * @see Struct
052 * @since 1.2
053 */
054 public interface Ref {
055
056 /**
057 * Retrieves the fully-qualified SQL name of the SQL structured type that
058 * this <code>Ref</code> object references.
059 *
060 * @return the fully-qualified SQL name of the referenced SQL structured type
061 * @exception SQLException if a database access error occurs
062 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
063 * this method
064 * @since 1.2
065 */
066 String getBaseTypeName() throws SQLException;
067
068 /**
069 * Retrieves the referenced object and maps it to a Java type
070 * using the given type map.
071 *
072 * @param map a <code>java.util.Map</code> object that contains
073 * the mapping to use (the fully-qualified name of the SQL
074 * structured type being referenced and the class object for
075 * <code>SQLData</code> implementation to which the SQL
076 * structured type will be mapped)
077 * @return a Java <code>Object</code> that is the custom mapping for
078 * the SQL structured type to which this <code>Ref</code>
079 * object refers
080 * @exception SQLException if a database access error occurs
081 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
082 * this method
083 * @since 1.4
084 * @see #setObject
085 */
086 Object getObject(java.util.Map<String, Class<?>> map)
087 throws SQLException;
088
089 /**
090 * Retrieves the SQL structured type instance referenced by
091 * this <code>Ref</code> object. If the connection's type map has an entry
092 * for the structured type, the instance will be custom mapped to
093 * the Java class indicated in the type map. Otherwise, the
094 * structured type instance will be mapped to a <code>Struct</code> object.
095 *
096 * @return a Java <code>Object</code> that is the mapping for
097 * the SQL structured type to which this <code>Ref</code>
098 * object refers
099 * @exception SQLException if a database access error occurs
100 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
101 * this method
102 * @since 1.4
103 * @see #setObject
104 */
105 Object getObject() throws SQLException;
106
107 /**
108 * Sets the structured type value that this <code>Ref</code>
109 * object references to the given instance of <code>Object</code>.
110 * The driver converts this to an SQL structured type when it
111 * sends it to the database.
112 *
113 * @param value an <code>Object</code> representing the SQL
114 * structured type instance that this
115 * <code>Ref</code> object will reference
116 * @exception SQLException if a database access error occurs
117 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
118 * this method
119 * @since 1.4
120 * @see #getObject()
121 * @see #getObject(Map)
122 * @see PreparedStatement#setObject(int, Object)
123 * @see CallableStatement#setObject(String, Object)
124 */
125 void setObject(Object value) throws SQLException;
126
127 }
|