Class Jdbc4SqlXmlHandler
- java.lang.Object
- org.springframework.jdbc.support.xml.Jdbc4SqlXmlHandler
- All Implemented Interfaces:
SqlXmlHandler
public class Jdbc4SqlXmlHandler extends Object implements SqlXmlHandler
Default implementation of theSqlXmlHandler
interface. Provides database-specific implementations for storing and retrieving XML documents to and from fields in a database, relying on the JDBC 4.0java.sql.SQLXML
facility.- Since:
- 2.5.6
- Author:
- Thomas Risberg, Juergen Hoeller
- See Also:
SQLXML
,ResultSet.getSQLXML(int)
,PreparedStatement.setSQLXML(int, java.sql.SQLXML)
Constructor Summary
Constructors Constructor Description Jdbc4SqlXmlHandler()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getXmlAsBinaryStream(ResultSet rs, int columnIndex)
Retrieve the given column as binary stream from the given ResultSet.InputStream
getXmlAsBinaryStream(ResultSet rs, String columnName)
Retrieve the given column as binary stream from the given ResultSet.Reader
getXmlAsCharacterStream(ResultSet rs, int columnIndex)
Retrieve the given column as character stream from the given ResultSet.Reader
getXmlAsCharacterStream(ResultSet rs, String columnName)
Retrieve the given column as character stream from the given ResultSet.Source
getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass)
Retrieve the given column as Source implemented using the specified source class from the given ResultSet.Source
getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass)
Retrieve the given column as Source implemented using the specified source class from the given ResultSet.String
getXmlAsString(ResultSet rs, int columnIndex)
Retrieve the given column as String from the given ResultSet.String
getXmlAsString(ResultSet rs, String columnName)
Retrieve the given column as String from the given ResultSet.SqlXmlValue
newSqlXmlValue(Class<? extends Result> resultClass, XmlResultProvider provider)
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.SqlXmlValue
newSqlXmlValue(String value)
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.SqlXmlValue
newSqlXmlValue(XmlBinaryStreamProvider provider)
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.SqlXmlValue
newSqlXmlValue(XmlCharacterStreamProvider provider)
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.SqlXmlValue
newSqlXmlValue(Document document)
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.
Constructor Detail
Jdbc4SqlXmlHandler
public Jdbc4SqlXmlHandler()
Method Detail
getXmlAsString
public String getXmlAsString(ResultSet rs, String columnName) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as String from the given ResultSet.Might simply invoke
ResultSet.getString
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsString
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use- Returns:
- the content as String, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getString(int)
,ResultSet.getSQLXML(int)
getXmlAsString
public String getXmlAsString(ResultSet rs, int columnIndex) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as String from the given ResultSet.Might simply invoke
ResultSet.getString
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsString
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- Returns:
- the content as String, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getString(int)
,ResultSet.getSQLXML(int)
getXmlAsBinaryStream
public InputStream getXmlAsBinaryStream(ResultSet rs, String columnName) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as binary stream from the given ResultSet.Might simply invoke
ResultSet.getAsciiStream
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsBinaryStream
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use- Returns:
- the content as a binary stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getBinaryStream()
getXmlAsBinaryStream
public InputStream getXmlAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as binary stream from the given ResultSet.Might simply invoke
ResultSet.getAsciiStream
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsBinaryStream
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- Returns:
- the content as binary stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getBinaryStream()
getXmlAsCharacterStream
public Reader getXmlAsCharacterStream(ResultSet rs, String columnName) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as character stream from the given ResultSet.Might simply invoke
ResultSet.getCharacterStream
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsCharacterStream
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to use- Returns:
- the content as character stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getCharacterStream()
getXmlAsCharacterStream
public Reader getXmlAsCharacterStream(ResultSet rs, int columnIndex) throws SQLException
Description copied from interface:SqlXmlHandler
Retrieve the given column as character stream from the given ResultSet.Might simply invoke
ResultSet.getCharacterStream
or work withSQLXML
or database-specific classes depending on the database and driver.- Specified by:
getXmlAsCharacterStream
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to use- Returns:
- the content as character stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getCharacterStream()
getXmlAsSource
public Source getXmlAsSource(ResultSet rs, String columnName, Class<? extends Source> sourceClass) throws SQLException
Description copied from interface:SqlXmlHandler
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.- Specified by:
getXmlAsSource
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnName
- the column name to usesourceClass
- the implementation class to be used- Returns:
- the content as character stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getSource(java.lang.Class<T>)
getXmlAsSource
public Source getXmlAsSource(ResultSet rs, int columnIndex, Class<? extends Source> sourceClass) throws SQLException
Description copied from interface:SqlXmlHandler
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.- Specified by:
getXmlAsSource
in interfaceSqlXmlHandler
- Parameters:
rs
- the ResultSet to retrieve the content fromcolumnIndex
- the column index to usesourceClass
- the implementation class to be used- Returns:
- the content as character stream, or
null
in case of SQL NULL - Throws:
SQLException
- if thrown by JDBC methods- See Also:
ResultSet.getSQLXML(int)
,SQLXML.getSource(java.lang.Class<T>)
newSqlXmlValue
public SqlXmlValue newSqlXmlValue(String value)
Description copied from interface:SqlXmlHandler
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.- Specified by:
newSqlXmlValue
in interfaceSqlXmlHandler
- Parameters:
value
- the XML String value providing XML data- Returns:
- the implementation specific instance
- See Also:
SqlXmlValue
,SQLXML.setString(String)
newSqlXmlValue
public SqlXmlValue newSqlXmlValue(XmlBinaryStreamProvider provider)
Description copied from interface:SqlXmlHandler
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.- Specified by:
newSqlXmlValue
in interfaceSqlXmlHandler
- Parameters:
provider
- theXmlBinaryStreamProvider
providing XML data- Returns:
- the implementation specific instance
- See Also:
SqlXmlValue
,SQLXML.setBinaryStream()
newSqlXmlValue
public SqlXmlValue newSqlXmlValue(XmlCharacterStreamProvider provider)
Description copied from interface:SqlXmlHandler
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.- Specified by:
newSqlXmlValue
in interfaceSqlXmlHandler
- Parameters:
provider
- theXmlCharacterStreamProvider
providing XML data- Returns:
- the implementation specific instance
- See Also:
SqlXmlValue
,SQLXML.setCharacterStream()
newSqlXmlValue
public SqlXmlValue newSqlXmlValue(Class<? extends Result> resultClass, XmlResultProvider provider)
Description copied from interface:SqlXmlHandler
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.- Specified by:
newSqlXmlValue
in interfaceSqlXmlHandler
- Parameters:
resultClass
- the Result implementation class to be usedprovider
- theXmlResultProvider
that will provide the XML data- Returns:
- the implementation specific instance
- See Also:
SqlXmlValue
,SQLXML.setResult(Class)
newSqlXmlValue
public SqlXmlValue newSqlXmlValue(Document document)
Description copied from interface:SqlXmlHandler
Create aSqlXmlValue
instance for the given XML data, as supported by the underlying JDBC driver.- Specified by:
newSqlXmlValue
in interfaceSqlXmlHandler
- Parameters:
document
- the XML Document to be used- Returns:
- the implementation specific instance
- See Also:
SqlXmlValue