Top Description Methods
org.springframework.jdbc.support.xml

public Interface SqlXmlHandler

Known Direct Implementers
org.springframework.jdbc.support.xml.Jdbc4SqlXmlHandler
Imports
java.io.InputStream, .Reader, java.sql.ResultSet, .SQLException, javax.xml.transform.Result, .Source, org.w3c.dom.Document, org.springframework.lang.Nullable

Abstraction for handling XML fields in specific databases. Its main purpose is to isolate database-specific handling of XML stored in the database.

JDBC 4.0 introduces the new data type java.sql.SQLXML but most databases and their drivers currently rely on database-specific data types and features.

Provides accessor methods for XML fields and acts as factory for SqlXmlValue instances.

Author
Thomas Risberg
Since
2.5.5
See Also
Jdbc4SqlXmlHandler, java.sql.SQLXML, java.sql.ResultSet#getSQLXML, java.sql.PreparedStatement#setSQLXML

Method Summary

Modifier and TypeMethod and Description
public InputStream

Returns:

the content as a binary stream, or null in case of SQL NULL
getXmlAsBinaryStream
(ResultSet
the ResultSet to retrieve the content from
rs
,
String
the column name to use
columnName
)

Retrieve the given column as binary stream from the given ResultSet.

public InputStream

Returns:

the content as binary stream, or null in case of SQL NULL
getXmlAsBinaryStream
(ResultSet
the ResultSet to retrieve the content from
rs
,
int
the column index to use
columnIndex
)

Retrieve the given column as binary stream from the given ResultSet.

public Reader

Returns:

the content as character stream, or null in case of SQL NULL
getXmlAsCharacterStream
(ResultSet
the ResultSet to retrieve the content from
rs
,
String
the column name to use
columnName
)

Retrieve the given column as character stream from the given ResultSet.

public Reader

Returns:

the content as character stream, or null in case of SQL NULL
getXmlAsCharacterStream
(ResultSet
the ResultSet to retrieve the content from
rs
,
int
the column index to use
columnIndex
)

Retrieve the given column as character stream from the given ResultSet.

public Source

Returns:

the content as character stream, or null in case of SQL NULL
getXmlAsSource
(ResultSet
the ResultSet to retrieve the content from
rs
,
String
the column name to use
columnName
,
Class<? extends Source>
the implementation class to be used
sourceClass
)

Retrieve the given column as Source implemented using the specified source class from the given ResultSet.

public Source

Returns:

the content as character stream, or null in case of SQL NULL
getXmlAsSource
(ResultSet
the ResultSet to retrieve the content from
rs
,
int
the column index to use
columnIndex
,
Class<? extends Source>
the implementation class to be used
sourceClass
)

Retrieve the given column as Source implemented using the specified source class from the given ResultSet.

public String

Returns:

the content as String, or null in case of SQL NULL
getXmlAsString
(ResultSet
the ResultSet to retrieve the content from
rs
,
String
the column name to use
columnName
)

Retrieve the given column as String from the given ResultSet.

public String

Returns:

the content as String, or null in case of SQL NULL
getXmlAsString
(ResultSet
the ResultSet to retrieve the content from
rs
,
int
the column index to use
columnIndex
)

Retrieve the given column as String from the given ResultSet.

public SqlXmlValue

Returns:

the implementation specific instance
newSqlXmlValue
(String
the XML String value providing XML data
value
)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

public SqlXmlValue

Returns:

the implementation specific instance
newSqlXmlValue
(XmlBinaryStreamProvider
the XmlBinaryStreamProvider providing XML data
provider
)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

public SqlXmlValue

Returns:

the implementation specific instance
newSqlXmlValue
(XmlCharacterStreamProvider
the XmlCharacterStreamProvider providing XML data
provider
)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

public SqlXmlValue

Returns:

the implementation specific instance
newSqlXmlValue
(Class<? extends Result>
the Result implementation class to be used
resultClass
,
XmlResultProvider
the XmlResultProvider that will provide the XML data
provider
)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

public SqlXmlValue

Returns:

the implementation specific instance
newSqlXmlValue
(Document
the XML Document to be used
doc
)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Method Detail

getXmlAsBinaryStreamback to summary
public InputStream getXmlAsBinaryStream(ResultSet rs, String columnName) throws SQLException

Retrieve the given column as binary stream from the given ResultSet.

Might simply invoke ResultSet.getAsciiStream or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnName:String

the column name to use

Returns:InputStream

the content as a binary stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getBinaryStream
getXmlAsBinaryStreamback to summary
public InputStream getXmlAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException

Retrieve the given column as binary stream from the given ResultSet.

Might simply invoke ResultSet.getAsciiStream or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnIndex:int

the column index to use

Returns:InputStream

the content as binary stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getBinaryStream
getXmlAsCharacterStreamback to summary
public Reader getXmlAsCharacterStream(ResultSet rs, String columnName) throws SQLException

Retrieve the given column as character stream from the given ResultSet.

Might simply invoke ResultSet.getCharacterStream or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnName:String

the column name to use

Returns:Reader

the content as character stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getCharacterStream
getXmlAsCharacterStreamback to summary
public Reader getXmlAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException

Retrieve the given column as character stream from the given ResultSet.

Might simply invoke ResultSet.getCharacterStream or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnIndex:int

the column index to use

Returns:Reader

the content as character stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getCharacterStream
getXmlAsSourceback to summary
public Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException

Retrieve the given column as Source implemented using the specified source class from the given ResultSet.

Might work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnName:String

the column name to use

sourceClass:Class<? extends Source>

the implementation class to be used

Returns:Source

the content as character stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getSource
getXmlAsSourceback to summary
public Source getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass) throws SQLException

Retrieve the given column as Source implemented using the specified source class from the given ResultSet.

Might work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnIndex:int

the column index to use

sourceClass:Class<? extends Source>

the implementation class to be used

Returns:Source

the content as character stream, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getSQLXML, java.sql.SQLXML#getSource
getXmlAsStringback to summary
public String getXmlAsString(ResultSet rs, String columnName) throws SQLException

Retrieve the given column as String from the given ResultSet.

Might simply invoke ResultSet.getString or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnName:String

the column name to use

Returns:String

the content as String, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getString, java.sql.ResultSet#getSQLXML
getXmlAsStringback to summary
public String getXmlAsString(ResultSet rs, int columnIndex) throws SQLException

Retrieve the given column as String from the given ResultSet.

Might simply invoke ResultSet.getString or work with SQLXML or database-specific classes depending on the database and driver.

Parameters
rs:ResultSet

the ResultSet to retrieve the content from

columnIndex:int

the column index to use

Returns:String

the content as String, or null in case of SQL NULL

Annotations
@Nullable
Exceptions
SQLException:
if thrown by JDBC methods
See Also
java.sql.ResultSet#getString, java.sql.ResultSet#getSQLXML
newSqlXmlValueback to summary
public SqlXmlValue newSqlXmlValue(String value)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Parameters
value:String

the XML String value providing XML data

Returns:SqlXmlValue

the implementation specific instance

See Also
SqlXmlValue, java.sql.SQLXML#setString(String)
newSqlXmlValueback to summary
public SqlXmlValue newSqlXmlValue(XmlBinaryStreamProvider provider)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Parameters
provider:XmlBinaryStreamProvider

the XmlBinaryStreamProvider providing XML data

Returns:SqlXmlValue

the implementation specific instance

See Also
SqlXmlValue, java.sql.SQLXML#setBinaryStream()
newSqlXmlValueback to summary
public SqlXmlValue newSqlXmlValue(XmlCharacterStreamProvider provider)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Parameters
provider:XmlCharacterStreamProvider

the XmlCharacterStreamProvider providing XML data

Returns:SqlXmlValue

the implementation specific instance

See Also
SqlXmlValue, java.sql.SQLXML#setCharacterStream()
newSqlXmlValueback to summary
public SqlXmlValue newSqlXmlValue(Class<? extends Result> resultClass, XmlResultProvider provider)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Parameters
resultClass:Class<? extends Result>

the Result implementation class to be used

provider:XmlResultProvider

the XmlResultProvider that will provide the XML data

Returns:SqlXmlValue

the implementation specific instance

See Also
SqlXmlValue, java.sql.SQLXML#setResult(Class)
newSqlXmlValueback to summary
public SqlXmlValue newSqlXmlValue(Document doc)

Create a SqlXmlValue instance for the given XML data, as supported by the underlying JDBC driver.

Parameters
doc:Document

the XML Document to be used

Returns:SqlXmlValue

the implementation specific instance

See Also
SqlXmlValue