- All Implemented Interfaces:
SQLOutput
public class SQLOutputImpl extends Object implements 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
Constructors Constructor Description SQLOutputImpl(Vector<?> attributes, Map<String,?> map)
Creates a newSQLOutputImpl
object initialized with the given vector of attributes and type map. -
Method Summary
Modifier and Type Method Description void
writeArray(Array x)
Writes anArray
object in the Java programming language to thisSQLOutputImpl
object.void
writeAsciiStream(InputStream x)
Writes a stream of ASCII characters to thisSQLOutputImpl
object.void
writeBigDecimal(BigDecimal x)
Writes ajava.math.BigDecimal
object in the Java programming language to thisSQLOutputImpl
object.void
writeBinaryStream(InputStream x)
Writes a stream of uninterpreted bytes to thisSQLOutputImpl
object.void
writeBlob(Blob x)
Writes aBlob
object in the Java programming language to thisSQLOutputImpl
object.void
writeBoolean(boolean x)
Writes aboolean
in the Java programming language to thisSQLOutputImpl
object.void
writeByte(byte x)
Writes abyte
in the Java programming language to thisSQLOutputImpl
object.void
writeBytes(byte[] x)
Writes an array ofbytes
in the Java programming language to thisSQLOutputImpl
object.void
writeCharacterStream(Reader x)
Writes a stream of Unicode characters to thisSQLOutputImpl
object.void
writeClob(Clob x)
Writes aClob
object in the Java programming language to thisSQLOutputImpl
object.void
writeDate(Date x)
Writes ajava.sql.Date
object in the Java programming language to thisSQLOutputImpl
object.void
writeDouble(double x)
Writes adouble
in the Java programming language to thisSQLOutputImpl
object.void
writeFloat(float x)
Writes afloat
in the Java programming language to thisSQLOutputImpl
object.void
writeInt(int x)
Writes anint
in the Java programming language to thisSQLOutputImpl
object.void
writeLong(long x)
Writes along
in the Java programming language to thisSQLOutputImpl
object.void
writeNClob(NClob x)
Writes an SQLNCLOB
value to the stream.void
writeNString(String x)
Writes the next attribute to the stream as aString
in the Java programming language.void
writeObject(SQLData x)
Writes to the stream the data contained in the givenSQLData
object.void
writeRef(Ref x)
Writes aRef
object in the Java programming language to thisSQLOutputImpl
object.void
writeRowId(RowId x)
Writes an SQLROWID
value to the stream.void
writeShort(short x)
Writes ashort
in the Java programming language to thisSQLOutputImpl
object.void
writeSQLXML(SQLXML x)
Writes an SQLXML
value to the stream.void
writeString(String x)
Writes aString
in the Java programming language to thisSQLOutputImpl
object.void
writeStruct(Struct x)
Writes aStruct
object in the Java programming language to thisSQLOutputImpl
object.void
writeTime(Time x)
Writes ajava.sql.Time
object in the Java programming language to thisSQLOutputImpl
object.void
writeTimestamp(Timestamp x)
Writes ajava.sql.Timestamp
object in the Java programming language to thisSQLOutputImpl
object.void
writeURL(URL url)
Writes anjava.sql.Type.DATALINK
object in the Java programming language to thisSQLOutputImpl
object.
-
Constructor Details
-
SQLOutputImpl
Creates a newSQLOutputImpl
object initialized with the given vector of attributes and type map. The driver will use the type map to determine whichSQLData.writeSQL
method to invoke. This method will then call the appropriateSQLOutputImpl
writer methods in order and thereby write the attributes to the new output stream.- Parameters:
attributes
- aVector
object containing the attributes of the UDT to be mapped to one or more objects in the Java programming languagemap
- ajava.util.Map
object containing zero or more entries, with each entry consisting of 1) aString
giving the fully qualified name of a UDT and 2) theClass
object for theSQLData
implementation that defines how the UDT is to be mapped- Throws:
SQLException
- if theattributes
or themap
is anull
value
-
-
Method Details
-
writeString
Writes aString
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLCHAR
,VARCHAR
, orLONGVARCHAR
before returning it to the database.- Specified by:
writeString
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeBoolean
Writes aboolean
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLBIT
before returning it to the database.- Specified by:
writeBoolean
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeByte
Writes abyte
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLBIT
before returning it to the database.- Specified by:
writeByte
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeShort
Writes ashort
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLSMALLINT
before returning it to the database.- Specified by:
writeShort
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeInt
Writes anint
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLINTEGER
before returning it to the database.- Specified by:
writeInt
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeLong
Writes along
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLBIGINT
before returning it to the database.- Specified by:
writeLong
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeFloat
Writes afloat
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLREAL
before returning it to the database.- Specified by:
writeFloat
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeDouble
Writes adouble
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLDOUBLE
before returning it to the database.- Specified by:
writeDouble
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeBigDecimal
Writes ajava.math.BigDecimal
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLNUMERIC
before returning it to the database.- Specified by:
writeBigDecimal
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeBytes
Writes an array ofbytes
in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLVARBINARY
orLONGVARBINARY
before returning it to the database.- Specified by:
writeBytes
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeDate
Writes ajava.sql.Date
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLDATE
before returning it to the database.- Specified by:
writeDate
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeTime
Writes ajava.sql.Time
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLTIME
before returning it to the database.- Specified by:
writeTime
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeTimestamp
Writes ajava.sql.Timestamp
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to an SQLTIMESTAMP
before returning it to the database.- Specified by:
writeTimestamp
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeCharacterStream
Writes a stream of Unicode characters to thisSQLOutputImpl
object. The driver will do any necessary conversion from Unicode to the databaseCHAR
format.- Specified by:
writeCharacterStream
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeAsciiStream
Writes a stream of ASCII characters to thisSQLOutputImpl
object. The driver will do any necessary conversion from ASCII to the databaseCHAR
format.- Specified by:
writeAsciiStream
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeBinaryStream
Writes a stream of uninterpreted bytes to thisSQLOutputImpl
object.- Specified by:
writeBinaryStream
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeObject
Writes to the stream the data contained in the givenSQLData
object. When theSQLData
object isnull
, this method writes an SQLNULL
to the stream. Otherwise, it calls theSQLData.writeSQL
method of the given object, which writes the object's attributes to the stream.The implementation of the method
SQLData.writeSQ
calls the appropriateSQLOutputImpl.writeXXX
method(s) for writing each of the object's attributes in order. The attributes must be read from anSQLInput
input stream and written to anSQLOutputImpl
output stream in the same order in which they were listed in the SQL definition of the user-defined type.- Specified by:
writeObject
in interfaceSQLOutput
- Parameters:
x
- the object representing data of an SQL structured or distinct type- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeRef
Writes aRef
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to a serializableSerialRef
SQLREF
value before returning it to the database.- Specified by:
writeRef
in interfaceSQLOutput
- Parameters:
x
- an object representing an SQLREF
value- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeBlob
Writes aBlob
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to a serializableSerialBlob
SQLBLOB
value before returning it to the database.- Specified by:
writeBlob
in interfaceSQLOutput
- Parameters:
x
- an object representing an SQLBLOB
value- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeClob
Writes aClob
object in the Java programming language to thisSQLOutputImpl
object. The driver converts it to a serializableSerialClob
SQLCLOB
value before returning it to the database.- Specified by:
writeClob
in interfaceSQLOutput
- Parameters:
x
- an object representing an SQLCLOB
value- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeStruct
Writes aStruct
object in the Java programming language to thisSQLOutputImpl
object. 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
Struct
object in the Java programming language (the standard mapping). The methodwriteObject
should be used if an SQL structured type has been custom mapped to a class in the Java programming language.- Specified by:
writeStruct
in interfaceSQLOutput
- Parameters:
x
- an object representing the attributes of an SQL structured type- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeArray
Writes anArray
object in the Java programming language to thisSQLOutputImpl
object. The driver converts this value to a serializableSerialArray
SQLARRAY
value before returning it to the database.- Specified by:
writeArray
in interfaceSQLOutput
- Parameters:
x
- an object representing an SQLARRAY
value- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeURL
Writes anjava.sql.Type.DATALINK
object in the Java programming language to thisSQLOutputImpl
object. The driver converts this value to a serializableSerialDatalink
SQLDATALINK
value before return it to the database.- Specified by:
writeURL
in interfaceSQLOutput
- Parameters:
url
- an object representing a SQLDATALINK
value- Throws:
SQLException
- if theSQLOutputImpl
object is in use by aSQLData
object attempting to write the attribute values of a UDT to the database.
-
writeNString
Writes the next attribute to the stream as aString
in the Java programming language. The driver converts this to a SQLNCHAR
orNVARCHAR
orLONGNVARCHAR
value (depending on the argument's size relative to the driver's limits onNVARCHAR
values) when it sends it to the stream.- Specified by:
writeNString
in interfaceSQLOutput
- Parameters:
x
- the value to pass to the database- Throws:
SQLException
- if a database access error occurs- Since:
- 1.6
-
writeNClob
Writes an SQLNCLOB
value to the stream.- Specified by:
writeNClob
in interfaceSQLOutput
- Parameters:
x
- aNClob
object representing data of an SQLNCLOB
value- Throws:
SQLException
- if a database access error occurs- Since:
- 1.6
-
writeRowId
Writes an SQLROWID
value to the stream.- Specified by:
writeRowId
in interfaceSQLOutput
- Parameters:
x
- aRowId
object representing data of an SQLROWID
value- Throws:
SQLException
- if a database access error occurs- Since:
- 1.6
-
writeSQLXML
Writes an SQLXML
value to the stream.- Specified by:
writeSQLXML
in interfaceSQLOutput
- Parameters:
x
- aSQLXML
object representing data of an SQLXML
value- Throws:
SQLException
- if a database access error occurs- Since:
- 1.6
-