- All Implemented Interfaces:
SQLOutput
When an application calls the
method PreparedStatement.setObject, the driver
checks to see whether the value to be written is a UDT with
a custom mapping. If it is, there will be an entry in a
type map containing the Class object for the
class that implements SQLData for this UDT.
If the value to be written is an instance of SQLData,
the driver will create an instance of SQLOutputImpl
and pass it to the method SQLData.writeSQL.
The method writeSQL in turn calls the
appropriate SQLOutputImpl.writeXXX methods
to write data from the SQLData object to
the SQLOutputImpl output stream as the
representation of an SQL user-defined type.
- Since:
- 1.5
-
Constructor Summary
ConstructorsConstructorDescriptionSQLOutputImpl(Vector<?> attributes, Map<String, ?> map) Creates a newSQLOutputImplobject initialized with the given vector of attributes and type map. -
Method Summary
Modifier and TypeMethodDescriptionvoidwriteArray(Array x) Writes anArrayobject in the Java programming language to thisSQLOutputImplobject.voidWrites a stream of ASCII characters to thisSQLOutputImplobject.voidWrites ajava.math.BigDecimalobject in the Java programming language to thisSQLOutputImplobject.voidWrites a stream of uninterpreted bytes to thisSQLOutputImplobject.voidWrites aBlobobject in the Java programming language to thisSQLOutputImplobject.voidwriteBoolean(boolean x) Writes abooleanin the Java programming language to thisSQLOutputImplobject.voidwriteByte(byte x) Writes abytein the Java programming language to thisSQLOutputImplobject.voidwriteBytes(byte[] x) Writes an array ofbytesin the Java programming language to thisSQLOutputImplobject.voidWrites a stream of Unicode characters to thisSQLOutputImplobject.voidWrites aClobobject in the Java programming language to thisSQLOutputImplobject.voidWrites ajava.sql.Dateobject in the Java programming language to thisSQLOutputImplobject.voidwriteDouble(double x) Writes adoublein the Java programming language to thisSQLOutputImplobject.voidwriteFloat(float x) Writes afloatin the Java programming language to thisSQLOutputImplobject.voidwriteInt(int x) Writes anintin the Java programming language to thisSQLOutputImplobject.voidwriteLong(long x) Writes alongin the Java programming language to thisSQLOutputImplobject.voidwriteNClob(NClob x) Writes an SQLNCLOBvalue to the stream.voidWrites the next attribute to the stream as aStringin the Java programming language.voidWrites to the stream the data contained in the givenSQLDataobject.voidWrites aRefobject in the Java programming language to thisSQLOutputImplobject.voidwriteRowId(RowId x) Writes an SQLROWIDvalue to the stream.voidwriteShort(short x) Writes ashortin the Java programming language to thisSQLOutputImplobject.voidWrites an SQLXMLvalue to the stream.voidWrites aStringin the Java programming language to thisSQLOutputImplobject.voidWrites aStructobject in the Java programming language to thisSQLOutputImplobject.voidWrites ajava.sql.Timeobject in the Java programming language to thisSQLOutputImplobject.voidWrites ajava.sql.Timestampobject in the Java programming language to thisSQLOutputImplobject.voidWrites anjava.sql.Type.DATALINKobject in the Java programming language to thisSQLOutputImplobject.Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods declared in interface java.sql.SQLOutput
writeObject
-
Constructor Details
-
SQLOutputImpl
Creates a newSQLOutputImplobject initialized with the given vector of attributes and type map. The driver will use the type map to determine whichSQLData.writeSQLmethod to invoke. This method will then call the appropriateSQLOutputImplwriter methods in order and thereby write the attributes to the new output stream.- Parameters:
attributes- aVectorobject containing the attributes of the UDT to be mapped to one or more objects in the Java programming languagemap- ajava.util.Mapobject containing zero or more entries, with each entry consisting of 1) aStringgiving the fully qualified name of a UDT and 2) theClassobject for theSQLDataimplementation that defines how the UDT is to be mapped- Throws:
SQLException- if theattributesor themapis anullvalue
-
-
Method Details
-
writeString
Writes aStringin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLCHAR,VARCHAR, orLONGVARCHARbefore returning it to the database.- Specified by:
writeStringin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeBoolean
Writes abooleanin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLBITbefore returning it to the database.- Specified by:
writeBooleanin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeByte
Writes abytein the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLBITbefore returning it to the database.- Specified by:
writeBytein interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeShort
Writes ashortin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLSMALLINTbefore returning it to the database.- Specified by:
writeShortin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeInt
Writes anintin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLINTEGERbefore returning it to the database.- Specified by:
writeIntin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeLong
Writes alongin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLBIGINTbefore returning it to the database.- Specified by:
writeLongin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeFloat
Writes afloatin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLREALbefore returning it to the database.- Specified by:
writeFloatin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeDouble
Writes adoublein the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLDOUBLEbefore returning it to the database.- Specified by:
writeDoublein interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeBigDecimal
Writes ajava.math.BigDecimalobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLNUMERICbefore returning it to the database.- Specified by:
writeBigDecimalin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeBytes
Writes an array ofbytesin the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLVARBINARYorLONGVARBINARYbefore returning it to the database.- Specified by:
writeBytesin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeDate
Writes ajava.sql.Dateobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLDATEbefore returning it to the database.- Specified by:
writeDatein interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeTime
Writes ajava.sql.Timeobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLTIMEbefore returning it to the database.- Specified by:
writeTimein interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeTimestamp
Writes ajava.sql.Timestampobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to an SQLTIMESTAMPbefore returning it to the database.- Specified by:
writeTimestampin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeCharacterStream
Writes a stream of Unicode characters to thisSQLOutputImplobject. The driver will do any necessary conversion from Unicode to the databaseCHARformat.- Specified by:
writeCharacterStreamin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeAsciiStream
Writes a stream of ASCII characters to thisSQLOutputImplobject. The driver will do any necessary conversion from ASCII to the databaseCHARformat.- Specified by:
writeAsciiStreamin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeBinaryStream
Writes a stream of uninterpreted bytes to thisSQLOutputImplobject.- Specified by:
writeBinaryStreamin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeObject
Writes to the stream the data contained in the givenSQLDataobject. When theSQLDataobject isnull, this method writes an SQLNULLto the stream. Otherwise, it calls theSQLData.writeSQLmethod of the given object, which writes the object's attributes to the stream.The implementation of the method
SQLData.writeSQcalls the appropriateSQLOutputImpl.writeXXXmethod(s) for writing each of the object's attributes in order. The attributes must be read from anSQLInputinput stream and written to anSQLOutputImploutput stream in the same order in which they were listed in the SQL definition of the user-defined type.- Specified by:
writeObjectin interfaceSQLOutput- Parameters:
x- the object representing data of an SQL structured or distinct type- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeRef
Writes aRefobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to a serializableSerialRefSQLREFvalue before returning it to the database.- Specified by:
writeRefin interfaceSQLOutput- Parameters:
x- an object representing an SQLREFvalue- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeBlob
Writes aBlobobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to a serializableSerialBlobSQLBLOBvalue before returning it to the database.- Specified by:
writeBlobin interfaceSQLOutput- Parameters:
x- an object representing an SQLBLOBvalue- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeClob
Writes aClobobject in the Java programming language to thisSQLOutputImplobject. The driver converts it to a serializableSerialClobSQLCLOBvalue before returning it to the database.- Specified by:
writeClobin interfaceSQLOutput- Parameters:
x- an object representing an SQLCLOBvalue- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeStruct
Writes aStructobject in the Java programming language to thisSQLOutputImplobject. The driver converts this value to an SQL structured type before returning it to the database.This method should be used when an SQL structured type has been mapped to a
Structobject in the Java programming language (the standard mapping). The methodwriteObjectshould be used if an SQL structured type has been custom mapped to a class in the Java programming language.- Specified by:
writeStructin interfaceSQLOutput- Parameters:
x- an object representing the attributes of an SQL structured type- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeArray
Writes anArrayobject in the Java programming language to thisSQLOutputImplobject. The driver converts this value to a serializableSerialArraySQLARRAYvalue before returning it to the database.- Specified by:
writeArrayin interfaceSQLOutput- Parameters:
x- an object representing an SQLARRAYvalue- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeURL
Writes anjava.sql.Type.DATALINKobject in the Java programming language to thisSQLOutputImplobject. The driver converts this value to a serializableSerialDatalinkSQLDATALINKvalue before return it to the database.- Specified by:
writeURLin interfaceSQLOutput- Parameters:
url- an object representing a SQLDATALINKvalue- Throws:
SQLException- if theSQLOutputImplobject is in use by aSQLDataobject attempting to write the attribute values of a UDT to the database.
-
writeNString
Writes the next attribute to the stream as aStringin the Java programming language. The driver converts this to a SQLNCHARorNVARCHARorLONGNVARCHARvalue (depending on the argument's size relative to the driver's limits onNVARCHARvalues) when it sends it to the stream.- Specified by:
writeNStringin interfaceSQLOutput- Parameters:
x- the value to pass to the database- Throws:
SQLException- if a database access error occurs- Since:
- 1.6
-
writeNClob
Writes an SQLNCLOBvalue to the stream.- Specified by:
writeNClobin interfaceSQLOutput- Parameters:
x- aNClobobject representing data of an SQLNCLOBvalue- Throws:
SQLException- if a database access error occurs- Since:
- 1.6
-
writeRowId
Writes an SQLROWIDvalue to the stream.- Specified by:
writeRowIdin interfaceSQLOutput- Parameters:
x- aRowIdobject representing data of an SQLROWIDvalue- Throws:
SQLException- if a database access error occurs- Since:
- 1.6
-
writeSQLXML
Writes an SQLXMLvalue to the stream.- Specified by:
writeSQLXMLin interfaceSQLOutput- Parameters:
x- aSQLXMLobject representing data of an SQLXMLvalue- Throws:
SQLException- if a database access error occurs- Since:
- 1.6
-