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