jdk/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/package.html
author chegar
Mon, 18 Aug 2014 10:59:36 +0100
changeset 25991 e48157b42439
parent 25976 jdk/src/share/classes/javax/sql/rowset/serial/package.html@4de01a56e3ee
parent 25859 jdk/src/share/classes/javax/sql/rowset/serial/package.html@3317bb8137f4
child 32210 958d823579c3
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
<html>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
<head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
                
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
  <meta http-equiv="Content-Type"
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 content="text/html; charset=iso-8859-1">
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
                
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
  <meta name="GENERATOR"
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 content="Mozilla/4.79 [en] (Windows NT 5.0; U) [Netscape]">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
<!--
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    11
Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
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
    16
published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    18
by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
5551
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    30
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    31
or visit www.oracle.com if you need additional information or have any
327690766109 6956202: Fix a few missed rebranding issues, please contact lines etc.
ohair
parents: 5506
diff changeset
    32
questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
-->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
<title>javax.sql.rowset.serial</title>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
</head>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
<body bgcolor="#ffffff">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
Provides utility classes to allow serializable mappings between SQL types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
and data types in the Java programming language.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
<p> Standard JDBC <code>RowSet</code> implementations may use these utility 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
classes to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
assist in the serialization of disconnected <code>RowSet</code> objects. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
This is useful
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
when  transmitting a disconnected <tt>RowSet</tt> object over the wire to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
a different VM or across layers within an application.<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
<h3>1.0 SerialArray</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
A serializable mapping in the Java programming language of an SQL ARRAY 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
value. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
The <tt>SerialArray </tt>class provides a constructor for creating a <tt>SerialArray
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
</tt>instance from an Array object, methods for getting the base type and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
the SQL name for the base type, and methods for copying all or part of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
<tt>SerialArray </tt>object. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
<h3>2.0 SerialBlob</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
A serializable mapping in the Java programming language of an SQL BLOB
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
value.  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
The <tt>SerialBlob </tt>class provides a constructor for creating an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
from a Blob object. Note that the Blob object should have brought the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
BLOB value's data over to the client before a <tt>SerialBlob </tt>object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
is constructed from it. The data of an SQL BLOB value can be materialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
on the client as an array of bytes (using the method <tt>Blob.getBytes</tt>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
or as a stream of uninterpreted bytes (using the method <tt>Blob.getBinaryStream</tt>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
<tt>SerialBlob </tt>methods make it possible to make a copy of a <tt>SerialBlob
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
</tt>object as an array of bytes or as a stream. They also make it possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
to locate a given pattern of bytes or a <tt>Blob </tt>object within a <tt>SerialBlob
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
</tt>object. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
<h3>3.0 SerialClob</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
A serializable mapping in the Java programming language of an SQL CLOB
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
value.  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
The <tt>SerialClob </tt>class provides a constructor for creating an instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
from a <tt>Clob </tt>object. Note that the <tt>Clob </tt>object should have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
brought the SQL CLOB value's data over to the client before a <tt>SerialClob
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
</tt>object is constructed from it. The data of an SQL CLOB value can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
materialized on the client as a stream of Unicode characters. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
<tt>SerialClob </tt>methods make it possible to get a substring from a 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
<tt>SerialClob </tt>object or to locate the start of a pattern of characters. 
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
<h3>5.0 SerialDatalink</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
A serializable mapping in the Java programming language of an SQL DATALINK
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
value. A DATALINK value references a file outside of the underlying data source
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 5551
diff changeset
    90
that the originating data source manages. <br>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
<code>RowSet</code> implementations can use the method <tt>RowSet.getURL() </tt>to retrieve
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
a <code>java.net.URL</code> object, which can be used to manipulate the external data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
&nbsp;&nbsp;<tt>&nbsp;&nbsp;&nbsp; java.net.URL url = rowset.getURL(1);</tt><br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
<h3>6.0 SerialJavaObject</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
A serializable mapping in the Java programming language of an SQL JAVA_OBJECT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
value. Assuming the Java object instance implements the Serializable interface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
this simply wraps the serialization process. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
If however, the serialization is not possible in the case where the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
object is not immediately serializable, this class will attempt to serialize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
all non static members to permit the object instance state to be serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
Static or transient fields cannot be serialized and attempting to do so 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
will result in a <tt>SerialException </tt>being thrown. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
<h3>7.0 SerialRef</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
A serializable mapping between the SQL REF type and the Java programming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
language. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
The <tt>SerialRef </tt>class provides a constructor for creating a <tt>SerialRef
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
</tt>instance from a <tt>Ref</tt> type and provides methods for getting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
and setting the <tt>Ref</tt> object type. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
<h3>8.0 SerialStruct</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
A serializable mapping in the Java programming language of an SQL structured
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
type. Each attribute that is not already serializable is mapped to a serializable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
form, and if an attribute is itself a structured type, each of its attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
that is not already serializable is mapped to a serializable form. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
In addition, if a <code>Map</code> object is passed to one of the constructors or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
to the method <code>getAttributes</code>, the structured type is custom mapped 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
according to the mapping specified in the <code>Map</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
  The <tt>SerialStruct </tt>class provides a constructor for creating an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
instance  from a <tt>Struct</tt> object, a method for retrieving the SQL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
type name of the SQL structured type in the database, and methods for retrieving
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
its attribute values. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
   
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
<h3>9.0 SQLInputImpl</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
  An input stream used for custom mapping user-defined types (UDTs). An 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
  <tt>SQLInputImpl</tt> object is an input stream that contains a stream of 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
  values that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
the attributes of a UDT. This class is used by the driver behind the scenes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
when the method <tt>getObject</tt> is called on an SQL structured or distinct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
type that has a custom mapping; a programmer never invokes <tt>SQLInputImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
</tt> methods directly. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
  The <tt>SQLInputImpl</tt> class provides a set of reader methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 analogous to the <tt>ResultSet</tt> getter methods. These methods make it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 possible to read the values in an <tt>SQLInputImpl</tt> object. The method
25976
4de01a56e3ee 8054555: javadoc cleanup for java.sql and javax.sql
lancea
parents: 5551
diff changeset
   144
<code>wasNull</code> is used to determine whether the last value read was SQL NULL.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
  When a constructor or getter method that takes a <code>Map</code> object is called, 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
the JDBC driver calls the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
<tt>SQLData.getSQLType</tt> to determine the SQL type of the UDT being custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
mapped. The driver  creates an instance of <code>SQLInputImpl</code>, populating it with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
the attributes of  the UDT. The driver then passes the input stream to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
method <tt>SQLData.readSQL</tt>,  which in turn calls the <tt>SQLInputImpl</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
methods to read the  attributes from the input stream. <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
   
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
<h3>10.0 SQLOutputImpl</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
  The output stream for writing the attributes of a custom mapped user-defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 type (UDT) back to the database. The driver uses this interface internally,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 and its methods are never directly invoked by an application programmer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
  <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
  When an application calls the method <tt>PreparedStatement.setObject, </tt>the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 driver checks to see whether the value to be written is a UDT with a custom
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 mapping. If it is, there will be an entry in a type map containing the Class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 object for the class that implements <tt>SQLData </tt>for this UDT. If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 value to be written is an instance of <tt>SQLData</tt>, the driver will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
create  an instance of <code>SQLOutputImpl</code> and pass it to the method 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
<tt>SQLData.writeSQL</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 The method <code>writeSQL</code> in turn calls the appropriate <tt>SQLOutputImpl</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
writer methods to write data from the <code>SQLData</code> object to the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
<code>SQLOutputImpl</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
output  stream as the representation of an SQL user-defined type.       
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
   
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
<h3>Custom Mapping</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
The JDBC API provides mechanisms for mapping an SQL structured type or DISTINCT 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
type to the Java programming language.  Typically, a structured type is mapped 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
to a class, and its attributes are mapped to fields in the class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
(A DISTINCT type can thought of as having one attribute.)  However, there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
many other possibilities, and there may be any number of different mappings.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
A programmer defines the mapping by implementing the interface <code>SQLData</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
For example, if an SQL structured type named AUTHORS has the attributes NAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
TITLE, and PUBLISHER, it could be mapped to a Java class named Authors.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
Authors class could have the fields name, title, and publisher, to which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
attributes of AUTHORS are mapped.  In such a case, the implementation of 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
<code>SQLData</code> could look like the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
<PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
   public class Authors implements SQLData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
       public String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
       public String title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
       public String publisher;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
       private String sql_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
       public String getSQLTypeName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
           return sql_type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
       public void readSQL(SQLInput stream, String type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                  throws SQLException  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
           sql_type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
           name = stream.readString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
           title = stream.readString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
           publisher = stream.readString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
       public void writeSQL(SQLOutput stream) throws SQLException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
           stream.writeString(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
           stream.writeString(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
           stream.writeString(publisher);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
       }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
   } 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
A <code>java.util.Map</code> object is used to associate the SQL structured
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
type with its mapping to the class <code>Authors</code>. The following code fragment shows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
how a <code>Map</code> object might be created and given an entry associating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
<code>AUTHORS</code> and <code>Authors</code>.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
<PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    java.util.Map map = new java.util.HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    map.put("SCHEMA_NAME.AUTHORS", Class.forName("Authors");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
The <code>Map</code> object <i>map</i> now contains an entry with the 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
fully qualified name of the SQL structured type and the <code>Class</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
 object for the class <code>Authors</code>.  It can be passed to a method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
to tell the driver how to map <code>AUTHORS</code> to <code>Authors</code>.  
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
<P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
For a disconnected <code>RowSet</code> object, custom mapping can be done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
only when a <code>Map</code> object is passed to the method or constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
that will be doing the custom mapping.  The situation is different for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
connected <code>RowSet</code> objects because they maintain a connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
with the data source.  A method that does custom mapping and is called by 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
a disconnected <code>RowSet</code> object may use the <code>Map</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
object that is associated with the <code>Connection</code> object being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
used. So, in other words, if no map is specified, the connection's type 
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
map can be used by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
</body>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
</html>