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