uTools-Manuals/docs/java/javax/sql/rowset/serial/package-summary.html

251 lines
14 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<h1 class="title" title="Package">Package javax.sql.rowset.serial</h1>
<div class="docSummary">
<div class="block">
提供实用程序类以允许Java编程语言中的SQL类型和数据类型之间的可序列化映射。
</div>
</div>
<p>See: <a href="#package.description">描述</a></p>
</div><div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" class="typeSummary" summary="Class Summary table, listing classes, and an explanation">
<caption>
<span>类摘要</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col"></th>
<th class="colLast" scope="col">描述</th>
</tr>
</tbody>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialArray.html" title="class in javax.sql.rowset.serial">SerialArray</a></td>
<td class="colLast">
<div class="block">
<code>Array</code>对象的序列化版本它是Java编程语言中SQL
<code>ARRAY</code>值的映射。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialBlob.html" title="class in javax.sql.rowset.serial">SerialBlob</a></td>
<td class="colLast">
<div class="block">
在Java编程语言中的序列化映射为SQL
<code>BLOB</code>值。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialClob.html" title="class in javax.sql.rowset.serial">SerialClob</a></td>
<td class="colLast">
<div class="block">
在Java编程语言中的序列化映射为SQL
<code>CLOB</code>值。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialDatalink.html" title="class in javax.sql.rowset.serial">SerialDatalink</a></td>
<td class="colLast">
<div class="block">
在Java编程语言中的序列化映射SQL
<code>DATALINK</code>值。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialJavaObject.html" title="class in javax.sql.rowset.serial">SerialJavaObject</a></td>
<td class="colLast">
<div class="block">
在Java编程语言中的序列化映射的SQL
<code>JAVA_OBJECT</code>值。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialRef.html" title="class in javax.sql.rowset.serial">SerialRef</a></td>
<td class="colLast">
<div class="block">
一个
<code>Ref</code>对象的序列化映射它是Java编程语言中的一个SQL
<code>REF</code>值的映射。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialStruct.html" title="class in javax.sql.rowset.serial">SerialStruct</a></td>
<td class="colLast">
<div class="block">
SQL编程语言中的SQL结构化类型的序列化映射。
</div> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SQLInputImpl.html" title="class in javax.sql.rowset.serial">SQLInputImpl</a></td>
<td class="colLast">
<div class="block">
用于自定义映射用户定义类型UDT的输入流。
</div> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SQLOutputImpl.html" title="class in javax.sql.rowset.serial">SQLOutputImpl</a></td>
<td class="colLast">
<div class="block">
用于将自定义映射的用户定义类型UDT的属性写入数据库的输出流。
</div> </td>
</tr>
</tbody>
</table> </li>
<li class="blockList">
<table border="0" cellpadding="3" cellspacing="0" class="typeSummary" summary="Exception Summary table, listing exceptions, and an explanation">
<caption>
<span>异常摘要</span>
<span class="tabEnd"> </span>
</caption>
<tbody>
<tr>
<th class="colFirst" scope="col">异常</th>
<th class="colLast" scope="col">描述</th>
</tr>
</tbody>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../../../../javax/sql/rowset/serial/SerialException.html" title="class in javax.sql.rowset.serial">SerialException</a></td>
<td class="colLast">
<div class="block">
表示SQL SERVER的序列化或解除序列化的错误
<code>BLOB, CLOB, STRUCT or ARRAY</code>除了SQL类型
<code>DATALINK and JAVAOBJECT</code>
</div> </td>
</tr>
</tbody>
</table> </li>
</ul>
<a name="package.description">
<!-- --> </a>
<h2 title="Package javax.sql.rowset.serial Description">Package javax.sql.rowset.serial Description</h2>
<div class="block">
<span>提供实用程序类以允许Java编程语言中的SQL类型和数据类型之间的可序列化映射。</span>
<p> <span>标准JDBC <code>RowSet</code>实现可以使用这些实用程序类来协助断开连接的<code>RowSet</code>对象的序列<code>RowSet</code></span> <span>当通过线路将断开连接的<tt>RowSet</tt>对象传输到应用程序中的不同VM或跨层时这是非常有用的。</span> <br/></p>
<h3> <span>1.0串行数组</span> </h3>
<span>SQL编程语言中的可序列化映射SQL ARRAY值。</span>
<br/>
<br/>
<span><tt>SerialArray</tt>类提供了一个从Array对象创建一个<tt>SerialArray</tt>实例的构造函数获取基类型的基本类型和SQL名称的方法以及复制<tt>SerialArray</tt>对象全部或部分的方法。</span>
<br/>
<h3> <span>2.0 SerialBlob</span> </h3>
<span>Java编程语言中的可序列化映射具有SQL BLOB值。</span>
<br/>
<br/>
<span><tt>SerialBlob</tt>类提供了一个用于从Blob对象创建实例的构造函数。</span>
<span>请注意Blob对象应该已经将SQL BLOB值的数据提交给客户端然后再从其中构建一个<tt>SerialBlob</tt>对象。</span>
<span>SQL BLOB值的数据可在客户端上以字节使用方法<tt>Blob.getBytes</tt>或作为未解释的字节流(使用方法<tt>Blob.getBinaryStream</tt>的阵列。</span>
<br/>
<br/>
<span><tt>SerialBlob</tt>方法可以使<tt>SerialBlob</tt>对象的副本作为字节数组或流。</span>
<span>它们还可以在<tt>SerialBlob</tt>对象中找到给定的字节模式或<tt>Blob</tt>对象。</span>
<br/>
<h3> <span>3.0 SerialClob</span> </h3>
<span>SQL编程语言中的可序列化映射SQL CLOB值。</span>
<br/>
<br/>
<span><tt>SerialClob</tt>类提供了一个用于从<tt>Clob</tt>对象创建实例的<tt>构造</tt>函数。</span>
<span>请注意, <tt>Clob</tt>对象应该将SQL CLOB值的数据转移到客户端然后再从其中构建一个<tt>SerialClob</tt>对象。</span>
<span>SQL CLOB值的数据可以作为Unicode字符流在客户端上实现。</span>
<br/>
<br/>
<span><tt>SerialClob</tt>方法可以从<tt>SerialClob</tt>对象获取一个子字符串,或查找字符模式的开始。</span>
<br/>
<h3> <span>5.0 SerialDatalink</span> </h3>
<span>SQL DATALINK值的Java编程语言中的可序列化映射。</span>
<span>DATALINK值引用始发数据源管理的底层数据源之外的文件。</span>
<br/>
<br/>
<span><code>RowSet</code>实现可以使用方法<tt>RowSet.getURL()</tt>来检索一个<code>java.net.URL</code>对象,可以用来操纵外部数据。</span>
<br/>
<br/>
<span><tt>    java.net.URL url = rowset.getURL(1);</tt></span>
<br/>
<h3> <span>6.0 SerialJavaObject</span> </h3>
<span>SQL JAVA_OBJECT值的Java编程语言中的可序列化映射。</span>
<span>假设Java对象实例实现了Serializable接口这简单地包装了序列化过程。</span>
<br/>
<br/>
<span>然而如果在Java对象不能立即可序列化的情况下序列化是不可能的则此类将尝试序列化所有非静态成员以允许对象实例状态被序列化。</span>
<span>静态或瞬态字段无法序列化,并尝试这样做会导致<tt>SerialException</tt>被抛出。</span>
<br/>
<h3> <span>7.0 SerialRef</span> </h3>
<span>SQL REF类型和Java编程语言之间的可序列化映射。</span>
<br/>
<br/>
<span><tt>SerialRef</tt>类提供了一个构造函数,用于从<tt>Ref</tt>类型创建一个<tt>SerialRef</tt>实例,并提供了获取和设置<tt>Ref</tt>对象类型的方法。</span>
<br/>
<h3> <span>8.0 SerialStruct</span> </h3>
<span>SQL结构化类型的Java编程语言中的可序列化映射。</span>
<span>每个不可序列化的属性被映射到可序列化的形式,如果一个属性本身是一个结构化类型,那么它的每个属性都不可序列化,它被映射到可序列化的形式。</span>
<br/>
<br/>
<span>另外,如果一个<code>Map</code>对象传递给其中一个构造函数或方法<code>getAttributes</code> ,则结构化类型根据<code>Map</code>对象中指定的映射进行自定义映射。</span>
<br/>
<span><tt>SerialStruct</tt>类提供了一个用于从<tt>Struct</tt>对象创建实例的<tt>构造</tt>函数一种用于检索数据库中SQL结构类型的SQL类型名称的方法以及用于检索其属性值的方法。</span>
<br/>
<h3> <span>9.0 SQLInputImpl</span> </h3>
<span>用于自定义映射用户定义类型UDT的输入流。</span>
<span><tt>SQLInputImpl</tt>对象是包含作为UDT属性的值的流的输入流。</span>
<span>当在具有自定义映射的SQL结构化或不同类型上调用方法<tt>getObject</tt>时,此类由驱动程序使用。</span>
<span>程序员从不直接调用<tt>SQLInputImpl</tt>方法。</span>
<br/>
<br/>
<span><tt>SQLInputImpl</tt>类提供了一组<tt>类似于ResultSet</tt>吸气剂方法的读取器方法。</span>
<span>这些方法可以读取<tt>SQLInputImpl</tt>对象中的值。</span>
<span>方法<code>wasNull</code>用于确定最后读取的值是否为SQL NULL。</span>
<br/>
<br/>
<span>当调用了一个构造函数或getter方法该方法调用了一个<code>Map</code>对象时JDBC驱动程序调用方法<tt>SQLData.getSQLType</tt>来确定定制映射的UDT的SQL类型。</span>
<span>驱动程序创建一个<code>SQLInputImpl</code>的实例用UDT的属性填充它。</span>
<span>然后,驱动程序将输入流传<tt>递到</tt>方法<tt>SQLData.readSQL</tt> ,方法<tt>SQLData.readSQL</tt>又调用<tt>SQLInputImpl</tt>方法从输入流读取属性。</span>
<br/>
<h3> <span>10.0 SQLOutputImpl</span> </h3>
<span>用于将自定义映射用户定义类型UDT的属性写入数据库的输出流。</span>
<span>驱动程序在内部使用此接口,并且其方法从不直接由应用程序编程器调用。</span>
<br/>
<br/>
<span>当应用程序调用方法<tt>PreparedStatement.setObject,时</tt> 驱动程序将检查要写入的值是否是具有自定义映射的UDT。</span>
<span>如果是,则类型映射中将包含<tt>一个</tt>包含该UDT SQLData的类的对象的条目。</span>
<span>要写入的值是<tt>SQLData的</tt>一个实例,驱动程序将创建一个<code>SQLOutputImpl</code>一个实例并传递给方法<tt>SQLData.writeSQL</tt></span>
<span>方法<code>writeSQL</code>依次调用适当的<tt>SQLOutputImpl</tt>写入器方法将数据从<code>SQLData</code>对象写入<code>SQLOutputImpl</code>输出流作为SQL用户定义类型的表示。</span>
<h3> <span>自定义映射</span> </h3>
<span>JDBC API提供了将SQL结构类型或DISTINCT类型映射到Java编程语言的机制。</span>
<span>通常,结构化类型映射到类,其属性映射到类中的字段。</span>
<span>DISTINCT类型可以被认为具有一个属性。然而还有许多其他可能性并且可能存在任何数量的不同映射。</span>
<p> <span>程序员通过实现接口定义的映射<code>SQLData</code></span> <span>例如如果名为AUTHORS的SQL结构类型具有NAMETITLE和PUBLISHER的属性则可将其映射到名为Authors的Java类。</span> <span>Authors类可以具有映射AUTHORS的属性的字段名称标题和发布者。</span> <span>在这种情况下SQLData的<code>SQLData</code>可能如下所示:</span> </p>
<pre> <span>public class Authors implements SQLData {
public String name;
public String title;
public String publisher;
private String sql_type;
public String getSQLTypeName() {
return sql_type;
}
public void readSQL(SQLInput stream, String type)
throws SQLException {
sql_type = type;
name = stream.readString();
title = stream.readString();
publisher = stream.readString();
}
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString(name);
stream.writeString(title);
stream.writeString(publisher);
}
}</span> </pre>
<span>A <code>java.util.Map</code>对象用于将SQL结构化类型与其映射<code>Authors</code>到类别<code>Authors</code></span>
<span>以下代码片段显示如何创建<code>Map</code>对象,并给出与<code>AUTHORS</code><code>Authors</code>的条目。</span>
<pre> <span>java.util.Map map = new java.util.HashMap();
map.put("SCHEMA_NAME.AUTHORS", Class.forName("Authors");</span> </pre>
<span><code>Map</code>对象<i>映射</i>现在包含一个具有SQL结构类型的完全合格的名称条目<code></code>对象类<code>Authors</code></span>
<span>它可以传递给一个方法来告诉司机如何将<code>AUTHORS</code>映射到<code>Authors</code></span>
<p> <span>对于断开连接的<code>RowSet</code>对象,仅当将<code>Map</code>对象传递给要执行自定义映射的方法或构造函数时,才能进行自定义映射。</span> <span>连接的<code>RowSet</code>对象的情况是不同的,因为它们保持与数据源的连接。</span> <span>执行自定义映射并由断开连接的<code>RowSet</code>对象调用的方法可以使用与<code>Map</code>使用的<code>Map</code>对象相关联的<code>Connection</code>对象。</span> <span>换句话说,如果没有指定地图,则默认情况下可以使用连接的类型映射。</span> <br/></p>
</div>
</div>