2828N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * The output stream for writing the attributes of a 0N/A * custom-mapped user-defined type (UDT) back to the database. 0N/A * The driver uses this interface internally, and its 0N/A * methods are never directly invoked by an application programmer. 0N/A * When an application calls the 0N/A * method <code>PreparedStatement.setObject</code>, the driver 0N/A * checks to see whether the value to be written is a UDT with 0N/A * a custom mapping. If it is, there will be an entry in a 0N/A * type map containing the <code>Class</code> object for the 0N/A * class that implements <code>SQLData</code> for this UDT. 0N/A * If the value to be written is an instance of <code>SQLData</code>, 0N/A * the driver will create an instance of <code>SQLOutputImpl</code> 0N/A * and pass it to the method <code>SQLData.writeSQL</code>. 0N/A * The method <code>writeSQL</code> in turn calls the 0N/A * appropriate <code>SQLOutputImpl.writeXXX</code> methods 0N/A * to write data from the <code>SQLData</code> object to 0N/A * the <code>SQLOutputImpl</code> output stream as the 0N/A * representation of an SQL user-defined type. 0N/A * A reference to an existing vector that 0N/A * contains the attributes of a <code>Struct</code> object. 0N/A * The type map the driver supplies to a newly created 0N/A * <code>SQLOutputImpl</code> object. This type map 0N/A * indicates the <code>SQLData</code> class whose 0N/A * <code>writeSQL</code> method will be called. This 0N/A * method will in turn call the appropriate 0N/A * <code>SQLOutputImpl</code> writer methods. 0N/A * Creates a new <code>SQLOutputImpl</code> object 0N/A * initialized with the given vector of attributes and 0N/A * type map. The driver will use the type map to determine 0N/A * which <code>SQLData.writeSQL</code> method to invoke. 0N/A * This method will then call the appropriate 0N/A * <code>SQLOutputImpl</code> writer methods in order and 0N/A * thereby write the attributes to the new output stream. 0N/A * @param attributes a <code>Vector</code> object containing the attributes of 0N/A * the UDT to be mapped to one or more objects in the Java 0N/A * programming language 0N/A * @param map a <code>java.util.Map</code> object containing zero or 0N/A * more entries, with each entry consisting of 1) a <code>String</code> 0N/A * giving the fully qualified name of a UDT and 2) the 0N/A * <code>Class</code> object for the <code>SQLData</code> implementation 0N/A * that defines how the UDT is to be mapped 0N/A * @throws SQLException if the <code>attributes</code> or the <code>map</code> 0N/A * is a <code>null</code> value 0N/A "instance with null parameters");
0N/A //================================================================ 0N/A // Methods for writing attributes to the stream of SQL data. 0N/A // These methods correspond to the column-accessor methods of 0N/A // java.sql.ResultSet. 0N/A //================================================================ 0N/A * Writes a <code>String</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>CHAR</code>, <code>VARCHAR</code>, or 0N/A * <code>LONGVARCHAR</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A //System.out.println("Adding :"+x); 0N/A * Writes a <code>boolean</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>BIT</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>byte</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>BIT</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>short</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>SMALLINT</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes an <code>int</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>INTEGER</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>long</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>BIGINT</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>float</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>REAL</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>double</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>DOUBLE</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>java.math.BigDecimal</code> object in the Java programming 0N/A * language to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>NUMERIC</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes an array of <code>bytes</code> in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>VARBINARY</code> or <code>LONGVARBINARY</code> 0N/A * before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>java.sql.Date</code> object in the Java programming 0N/A * language to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>DATE</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>java.sql.Time</code> object in the Java programming 0N/A * language to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>TIME</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>java.sql.Timestamp</code> object in the Java programming 0N/A * language to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to an SQL <code>TIMESTAMP</code> before returning it to the database. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a stream of Unicode characters to this 0N/A * <code>SQLOutputImpl</code> object. The driver will do any necessary 0N/A * conversion from Unicode to the database <code>CHAR</code> format. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a stream of ASCII characters to this 0N/A * <code>SQLOutputImpl</code> object. The driver will do any necessary 0N/A * conversion from ASCII to the database <code>CHAR</code> format. 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a stream of uninterpreted bytes to this <code>SQLOutputImpl</code> 0N/A * @param x the value to pass to the database 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A //================================================================ 0N/A // Methods for writing items of SQL user-defined types to the stream. 0N/A // These methods pass objects to the database as values of SQL 0N/A // Structured Types, Distinct Types, Constructed Types, and Locator 0N/A // Types. They decompose the Java object(s) and write leaf data 0N/A // items using the methods above. 0N/A //================================================================ 0N/A * Writes to the stream the data contained in the given 0N/A * <code>SQLData</code> object. 0N/A * When the <code>SQLData</code> object is <code>null</code>, this 0N/A * method writes an SQL <code>NULL</code> to the stream. 0N/A * Otherwise, it calls the <code>SQLData.writeSQL</code> 0N/A * method of the given object, which 0N/A * writes the object's attributes to the stream. 0N/A * The implementation of the method <code>SQLData.writeSQ</code> 0N/A * calls the appropriate <code>SQLOutputImpl.writeXXX</code> method(s) 0N/A * for writing each of the object's attributes in order. 0N/A * The attributes must be read from an <code>SQLInput</code> 0N/A * input stream and written to an <code>SQLOutputImpl</code> 0N/A * output stream in the same order in which they were 0N/A * listed in the SQL definition of the user-defined type. 0N/A * @param x the object representing data of an SQL structured or 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Except for the types that are passed as objects 0N/A * this seems to be the only way for an object to 0N/A * get a null value for a field in a structure. 0N/A * Note: this means that the class defining SQLData 0N/A * will need to track if a field is SQL null for itself 0N/A * We have to write out a SerialStruct that contains 0N/A * the name of this class otherwise we don't know 0N/A * what to re-instantiate during readSQL() 0N/A * Writes a <code>Ref</code> object in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to a serializable <code>SerialRef</code> SQL <code>REF</code> value 0N/A * before returning it to the database. 0N/A * @param x an object representing an SQL <code>REF</code> value 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>Blob</code> object in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to a serializable <code>SerialBlob</code> SQL <code>BLOB</code> value 0N/A * before returning it to the database. 0N/A * @param x an object representing an SQL <code>BLOB</code> value 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>Clob</code> object in the Java programming language 0N/A * to this <code>SQLOutputImpl</code> object. The driver converts 0N/A * it to a serializable <code>SerialClob</code> SQL <code>CLOB</code> value 0N/A * before returning it to the database. 0N/A * @param x an object representing an SQL <code>CLOB</code> value 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes a <code>Struct</code> object in the Java 0N/A * programming language to this <code>SQLOutputImpl</code> 0N/A * object. The driver converts this value to an SQL structured type 0N/A * before returning it to the database. 0N/A * This method should be used when an SQL structured type has been 0N/A * mapped to a <code>Struct</code> object in the Java programming 0N/A * language (the standard mapping). The method 0N/A * <code>writeObject</code> should be used if an SQL structured type 0N/A * has been custom mapped to a class in the Java programming language. 0N/A * @param x an object representing the attributes of an SQL structured type 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes an <code>Array</code> object in the Java 0N/A * programming language to this <code>SQLOutputImpl</code> 0N/A * object. The driver converts this value to a serializable 0N/A * <code>SerialArray</code> SQL <code>ARRAY</code> 0N/A * value before returning it to the database. 0N/A * @param x an object representing an SQL <code>ARRAY</code> value 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes an <code>java.sql.Type.DATALINK</code> object in the Java 0N/A * programming language to this <code>SQLOutputImpl</code> object. The 0N/A * driver converts this value to a serializable <code>SerialDatalink</code> 0N/A * SQL <code>DATALINK</code> value before return it to the database. 0N/A * @param url an object representing a SQL <code>DATALINK</code> value 0N/A * @throws SQLException if the <code>SQLOutputImpl</code> object is in 0N/A * use by a <code>SQLData</code> object attempting to write the attribute 0N/A * values of a UDT to the database. 0N/A * Writes the next attribute to the stream as a <code>String</code> 0N/A * in the Java programming language. The driver converts this to a 0N/A * SQL <code>NCHAR</code> or 0N/A * <code>NVARCHAR</code> or <code>LONGNVARCHAR</code> value 0N/A * (depending on the argument's 0N/A * size relative to the driver's limits on <code>NVARCHAR</code> values) 0N/A * when it sends it to the stream. 0N/A * @param x the value to pass to the database 0N/A * @exception SQLException if a database access error occurs 0N/A * Writes an SQL <code>NCLOB</code> value to the stream. 0N/A * @param x a <code>NClob</code> object representing data of an SQL 0N/A * <code>NCLOB</code> value 0N/A * @exception SQLException if a database access error occurs 0N/A * Writes an SQL <code>ROWID</code> value to the stream. 0N/A * @param x a <code>RowId</code> object representing data of an SQL 0N/A * <code>ROWID</code> value 0N/A * @exception SQLException if a database access error occurs 0N/A * Writes an SQL <code>XML</code> value to the stream. 0N/A * @param x a <code>SQLXML</code> object representing data of an SQL 0N/A * <code>XML</code> value 0N/A * @exception SQLException if a database access error occurs