SQLOutputImpl (Java Platform SE 6) (original) (raw)
javax.sql.rowset.serial
Class SQLOutputImpl
java.lang.Object
javax.sql.rowset.serial.SQLOutputImpl
All Implemented Interfaces:
public class SQLOutputImpl
extends Object
implements SQLOutput
The output stream for writing the attributes of a custom-mapped user-defined type (UDT) back to the database. The driver uses this interface internally, and its methods are never directly invoked by an application programmer.
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.
Constructor Summary |
---|
[SQLOutputImpl](../../../../javax/sql/rowset/serial/SQLOutputImpl.html#SQLOutputImpl%28java.util.Vector, java.util.Map%29)(Vector attributes,[Map](../../../../java/util/Map.html "interface in java.util")<[String](../../../../java/lang/String.html "class in java.lang"),?> map) Creates a new SQLOutputImpl object initialized with the given vector of attributes and type map. |
Method Summary | |
---|---|
void | writeArray(Array x) Writes an Array object in the Java programming language to this SQLOutputImpl object. |
void | writeAsciiStream(InputStream x) Writes a stream of ASCII characters to thisSQLOutputImpl object. |
void | writeBigDecimal(BigDecimal x) Writes a java.math.BigDecimal object in the Java programming language to this SQLOutputImpl object. |
void | writeBinaryStream(InputStream x) Writes a stream of uninterpreted bytes to this SQLOutputImpl object. |
void | writeBlob(Blob x) Writes a Blob object in the Java programming language to this SQLOutputImpl object. |
void | writeBoolean(boolean x) Writes a boolean in the Java programming language to this SQLOutputImpl object. |
void | writeByte(byte x) Writes a byte in the Java programming language to this SQLOutputImpl object. |
void | writeBytes(byte[] x) Writes an array of bytes in the Java programming language to this SQLOutputImpl object. |
void | writeCharacterStream(Reader x) Writes a stream of Unicode characters to thisSQLOutputImpl object. |
void | writeClob(Clob x) Writes a Clob object in the Java programming language to this SQLOutputImpl object. |
void | writeDate(Date x) Writes a java.sql.Date object in the Java programming language to this SQLOutputImpl object. |
void | writeDouble(double x) Writes a double in the Java programming language to this SQLOutputImpl object. |
void | writeFloat(float x) Writes a float in the Java programming language to this SQLOutputImpl object. |
void | writeInt(int x) Writes an int in the Java programming language to this SQLOutputImpl object. |
void | writeLong(long x) Writes a long in the Java programming language to this SQLOutputImpl object. |
void | writeNClob(NClob x) Writes an SQL NCLOB value to the stream. |
void | writeNString(String x) Writes the next attribute to the stream as a String in the Java programming language. |
void | writeObject(SQLData x) Writes to the stream the data contained in the given SQLData object. |
void | writeRef(Ref x) Writes a Ref object in the Java programming language to this SQLOutputImpl object. |
void | writeRowId(RowId x) Writes an SQL ROWID value to the stream. |
void | writeShort(short x) Writes a short in the Java programming language to this SQLOutputImpl object. |
void | writeSQLXML(SQLXML x) Writes an SQL XML value to the stream. |
void | writeString(String x) Writes a String in the Java programming language to this SQLOutputImpl object. |
void | writeStruct(Struct x) Writes a Struct object in the Java programming language to this SQLOutputImpl object. |
void | writeTime(Time x) Writes a java.sql.Time object in the Java programming language to this SQLOutputImpl object. |
void | writeTimestamp(Timestamp x) Writes a java.sql.Timestamp object in the Java programming language to this SQLOutputImpl object. |
void | writeURL(URL url) Writes an java.sql.Type.DATALINK object in the Java programming language to this SQLOutputImpl object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../../java/lang/Object.html#wait%28long, int%29) |
Constructor Detail |
---|
SQLOutputImpl
public SQLOutputImpl(Vector attributes, [Map](../../../../java/util/Map.html "interface in java.util")<[String](../../../../java/lang/String.html "class in java.lang"),?> map) throws SQLException
Creates a new SQLOutputImpl
object initialized with the given vector of attributes and type map. The driver will use the type map to determine which SQLData.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
- a Vector
object containing the attributes of the UDT to be mapped to one or more objects in the Java programming language
map
- a java.util.Map
object containing zero or more entries, with each entry consisting of 1) a String
giving the fully qualified name of a UDT and 2) theClass
object for the SQLData
implementation that defines how the UDT is to be mapped
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the attributes
or the map
is a null
value
Method Detail |
---|
writeString
public void writeString(String x) throws SQLException
Writes a String
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL CHAR
, VARCHAR
, or LONGVARCHAR
before returning it to the database.
Specified by:
[writeString](../../../../java/sql/SQLOutput.html#writeString%28java.lang.String%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeBoolean
public void writeBoolean(boolean x) throws SQLException
Writes a boolean
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL BIT
before returning it to the database.
Specified by:
[writeBoolean](../../../../java/sql/SQLOutput.html#writeBoolean%28boolean%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeByte
public void writeByte(byte x) throws SQLException
Writes a byte
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL BIT
before returning it to the database.
Specified by:
[writeByte](../../../../java/sql/SQLOutput.html#writeByte%28byte%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeShort
public void writeShort(short x) throws SQLException
Writes a short
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL SMALLINT
before returning it to the database.
Specified by:
[writeShort](../../../../java/sql/SQLOutput.html#writeShort%28short%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeInt
public void writeInt(int x) throws SQLException
Writes an int
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL INTEGER
before returning it to the database.
Specified by:
[writeInt](../../../../java/sql/SQLOutput.html#writeInt%28int%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeLong
public void writeLong(long x) throws SQLException
Writes a long
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL BIGINT
before returning it to the database.
Specified by:
[writeLong](../../../../java/sql/SQLOutput.html#writeLong%28long%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeFloat
public void writeFloat(float x) throws SQLException
Writes a float
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL REAL
before returning it to the database.
Specified by:
[writeFloat](../../../../java/sql/SQLOutput.html#writeFloat%28float%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeDouble
public void writeDouble(double x) throws SQLException
Writes a double
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL DOUBLE
before returning it to the database.
Specified by:
[writeDouble](../../../../java/sql/SQLOutput.html#writeDouble%28double%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeBigDecimal
public void writeBigDecimal(BigDecimal x) throws SQLException
Writes a java.math.BigDecimal
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL NUMERIC
before returning it to the database.
Specified by:
[writeBigDecimal](../../../../java/sql/SQLOutput.html#writeBigDecimal%28java.math.BigDecimal%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeBytes
public void writeBytes(byte[] x) throws SQLException
Writes an array of bytes
in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL VARBINARY
or LONGVARBINARY
before returning it to the database.
Specified by:
[writeBytes](../../../../java/sql/SQLOutput.html#writeBytes%28byte[]%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeDate
public void writeDate(Date x) throws SQLException
Writes a java.sql.Date
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL DATE
before returning it to the database.
Specified by:
[writeDate](../../../../java/sql/SQLOutput.html#writeDate%28java.sql.Date%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeTime
public void writeTime(Time x) throws SQLException
Writes a java.sql.Time
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL TIME
before returning it to the database.
Specified by:
[writeTime](../../../../java/sql/SQLOutput.html#writeTime%28java.sql.Time%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeTimestamp
public void writeTimestamp(Timestamp x) throws SQLException
Writes a java.sql.Timestamp
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to an SQL TIMESTAMP
before returning it to the database.
Specified by:
[writeTimestamp](../../../../java/sql/SQLOutput.html#writeTimestamp%28java.sql.Timestamp%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeCharacterStream
public void writeCharacterStream(Reader x) throws SQLException
Writes a stream of Unicode characters to thisSQLOutputImpl
object. The driver will do any necessary conversion from Unicode to the database CHAR
format.
Specified by:
[writeCharacterStream](../../../../java/sql/SQLOutput.html#writeCharacterStream%28java.io.Reader%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeAsciiStream
public void writeAsciiStream(InputStream x) throws SQLException
Writes a stream of ASCII characters to thisSQLOutputImpl
object. The driver will do any necessary conversion from ASCII to the database CHAR
format.
Specified by:
[writeAsciiStream](../../../../java/sql/SQLOutput.html#writeAsciiStream%28java.io.InputStream%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeBinaryStream
public void writeBinaryStream(InputStream x) throws SQLException
Writes a stream of uninterpreted bytes to this SQLOutputImpl
object.
Specified by:
[writeBinaryStream](../../../../java/sql/SQLOutput.html#writeBinaryStream%28java.io.InputStream%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeObject
public void writeObject(SQLData x) throws SQLException
Writes to the stream the data contained in the given SQLData
object. When the SQLData
object is null
, this method writes an SQL NULL
to the stream. Otherwise, it calls the SQLData.writeSQL
method of the given object, which writes the object's attributes to the stream.
The implementation of the method SQLData.writeSQ
calls the appropriate SQLOutputImpl.writeXXX
method(s) for writing each of the object's attributes in order. The attributes must be read from an SQLInput
input stream and written to an SQLOutputImpl
output stream in the same order in which they were listed in the SQL definition of the user-defined type.
Specified by:
[writeObject](../../../../java/sql/SQLOutput.html#writeObject%28java.sql.SQLData%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the object representing data of an SQL structured or distinct type
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeRef
public void writeRef(Ref x) throws SQLException
Writes a Ref
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to a serializable SerialRef
SQL REF
value before returning it to the database.
Specified by:
[writeRef](../../../../java/sql/SQLOutput.html#writeRef%28java.sql.Ref%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- an object representing an SQL REF
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeBlob
public void writeBlob(Blob x) throws SQLException
Writes a Blob
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to a serializable SerialBlob
SQL BLOB
value before returning it to the database.
Specified by:
[writeBlob](../../../../java/sql/SQLOutput.html#writeBlob%28java.sql.Blob%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- an object representing an SQL BLOB
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeClob
public void writeClob(Clob x) throws SQLException
Writes a Clob
object in the Java programming language to this SQLOutputImpl
object. The driver converts it to a serializable SerialClob
SQL CLOB
value before returning it to the database.
Specified by:
[writeClob](../../../../java/sql/SQLOutput.html#writeClob%28java.sql.Clob%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- an object representing an SQL CLOB
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeStruct
public void writeStruct(Struct x) throws SQLException
Writes a Struct
object in the Java programming language to this SQLOutputImpl
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 method writeObject
should be used if an SQL structured type has been custom mapped to a class in the Java programming language.
Specified by:
[writeStruct](../../../../java/sql/SQLOutput.html#writeStruct%28java.sql.Struct%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- an object representing the attributes of an SQL structured type
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeArray
public void writeArray(Array x) throws SQLException
Writes an Array
object in the Java programming language to this SQLOutputImpl
object. The driver converts this value to a serializable SerialArray
SQL ARRAY
value before returning it to the database.
Specified by:
[writeArray](../../../../java/sql/SQLOutput.html#writeArray%28java.sql.Array%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- an object representing an SQL ARRAY
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeURL
public void writeURL(URL url) throws SQLException
Writes an java.sql.Type.DATALINK
object in the Java programming language to this SQLOutputImpl
object. The driver converts this value to a serializable SerialDatalink
SQL DATALINK
value before return it to the database.
Specified by:
[writeURL](../../../../java/sql/SQLOutput.html#writeURL%28java.net.URL%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
url
- an object representing a SQL DATALINK
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if the SQLOutputImpl
object is in use by a SQLData
object attempting to write the attribute values of a UDT to the database.
writeNString
public void writeNString(String x) throws SQLException
Writes the next attribute to the stream as a String
in the Java programming language. The driver converts this to a SQL NCHAR
orNVARCHAR
or LONGNVARCHAR
value (depending on the argument's size relative to the driver's limits on NVARCHAR
values) when it sends it to the stream.
Specified by:
[writeNString](../../../../java/sql/SQLOutput.html#writeNString%28java.lang.String%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- the value to pass to the database
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if a database access error occurs
Since:
1.6
writeNClob
public void writeNClob(NClob x) throws SQLException
Writes an SQL NCLOB
value to the stream.
Specified by:
[writeNClob](../../../../java/sql/SQLOutput.html#writeNClob%28java.sql.NClob%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- a NClob
object representing data of an SQLNCLOB
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if a database access error occurs
Since:
1.6
writeRowId
public void writeRowId(RowId x) throws SQLException
Writes an SQL ROWID
value to the stream.
Specified by:
[writeRowId](../../../../java/sql/SQLOutput.html#writeRowId%28java.sql.RowId%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- a RowId
object representing data of an SQLROWID
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if a database access error occurs
Since:
1.6
writeSQLXML
public void writeSQLXML(SQLXML x) throws SQLException
Writes an SQL XML
value to the stream.
Specified by:
[writeSQLXML](../../../../java/sql/SQLOutput.html#writeSQLXML%28java.sql.SQLXML%29)
in interface [SQLOutput](../../../../java/sql/SQLOutput.html "interface in java.sql")
Parameters:
x
- a SQLXML
object representing data of an SQLXML
value
Throws:
[SQLException](../../../../java/sql/SQLException.html "class in java.sql")
- if a database access error occurs
Since:
1.6
Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.