com.ibm.as400.access
Class AS400JDBCSQLXML
- java.lang.Object
-
- com.ibm.as400.access.AS400JDBCSQLXML
-
- All Implemented Interfaces:
- java.sql.SQLXML
- Direct Known Subclasses:
- AS400JDBCSQLXMLLocator
public class AS400JDBCSQLXML extends java.lang.Object implements java.sql.SQLXMLThis class provides the object interface for using XML data through JDBC. The mapping in the Java programming language for the SQL XML type. XML is a built-in type that stores an XML value as a column value in a row of a database table. The SQLXML interface provides methods for accessing the XML value as a String, a Reader or Writer, or as a Stream. This class returns the data as an XML type. The actual type on the host may vary. Instances of this class are created by AS400JDBCConnection. This class should not be used if JDK 1.6 is not in use.
-
-
Field Summary
Fields Modifier and Type Field and Description protected booleanisXML_
-
Constructor Summary
Constructors Modifier Constructor and Description protectedAS400JDBCSQLXML()Constructs an AS400JDBCSQLXML object.
-
Method Summary
Methods Modifier and Type Method and Description voidfree()This method frees the object and releases the the resources that it holds.java.io.InputStreamgetBinaryStream()Retrieves the XML value designated by this SQLXML instance as a stream.java.io.ReadergetCharacterStream()Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object.<T extends javax.xml.transform.Source>
TgetSource(java.lang.Class<T> sourceClass)Returns a Source for reading the XML value designated by this SQLXML instance.java.lang.StringgetString()Retrieves a string representation of the XML value designated by thisSQLXMLobject.java.io.OutputStreamsetBinaryStream()Retrieves a stream that can be used to write the XML value that this SQLXML instance represents.java.io.WritersetCharacterStream()Retrieves a Writer to be used to write the XML value that this SQLXML instance represents.<T extends javax.xml.transform.Result>
TsetResult(java.lang.Class<T> resultClass)Returns a Result for setting the XML value designated by this SQLXML instance.voidsetString(java.lang.String str)Writes the given Java String to the XML value that thisSQLXMLobject designates.
-
-
-
Constructor Detail
-
AS400JDBCSQLXML
protected AS400JDBCSQLXML()
Constructs an AS400JDBCSQLXML object. This is only a dummy constructor used by subclasses.
-
-
Method Detail
-
getCharacterStream
public java.io.Reader getCharacterStream() throws java.sql.SQLExceptionRetrieves the XML value designated by this SQLXML instance as a java.io.Reader object. The format of this stream is defined by org.xml.sax.InputSource, where the characters in the stream represent the Unicode code points for XML according to section 2 and appendix B of the XML 1.0 specification. Although an encoding declaration other than Unicode may be present, the encoding of the stream is Unicode. The behavior of this method is the same as ResultSet.getCharacterStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.
- Specified by:
getCharacterStreamin interfacejava.sql.SQLXML- Returns:
- a stream containing the XML data.
- Throws:
java.sql.SQLException- if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not readable.
-
getString
public java.lang.String getString() throws java.sql.SQLExceptionRetrieves a string representation of the XML value designated by thisSQLXMLobject.- Specified by:
getStringin interfacejava.sql.SQLXML- Returns:
- a String that is the string representation of the XML value
- Throws:
java.sql.SQLException- if there is an error accessing the XML value
-
setString
public void setString(java.lang.String str) throws java.sql.SQLExceptionWrites the given Java String to the XML value that thisSQLXMLobject designates.- Specified by:
setStringin interfacejava.sql.SQLXML- Parameters:
str- the string to be written to the XML value that thisSQLXMLdesignates- Throws:
java.sql.SQLException- if there is an error accessing the XML value
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLExceptionRetrieves the XML value designated by this SQLXML instance as a stream.- Specified by:
getBinaryStreamin interfacejava.sql.SQLXML- Returns:
- a stream containing the XML data.
- Throws:
java.sql.SQLException- if there is an error processing the XML value. An exception is thrown if the state is not readable.
-
getSource
public <T extends javax.xml.transform.Source> T getSource(java.lang.Class<T> sourceClass) throws java.sql.SQLExceptionReturns a Source for reading the XML value designated by this SQLXML instance. Sources are used as inputs to XML parsers and XSLT transformers.- Specified by:
getSourcein interfacejava.sql.SQLXML- Parameters:
sourceClass- The class of the source, or null. If the class is null, a vendor specific Source implementation will be returned. The following classes are supported at a minimum:javax.xml.transform.dom.DOMSource - returns a DOMSource javax.xml.transform.sax.SAXSource - returns a SAXSource javax.xml.transform.stax.StAXSource - returns a StAXSource javax.xml.transform.stream.StreamSource - returns a StreamSource
- Returns:
- a Source for reading the XML value.
- Throws:
java.sql.SQLException- if there is an error processing the XML value or if this feature is not supported. The getCause() method of the exception may provide a more detailed exception, for example, if an XML parser exception occurs. An exception is thrown if the state is not readable.
-
setBinaryStream
public java.io.OutputStream setBinaryStream() throws java.sql.SQLExceptionRetrieves a stream that can be used to write the XML value that this SQLXML instance represents.- Specified by:
setBinaryStreamin interfacejava.sql.SQLXML- Returns:
- a stream to which data can be written.
- Throws:
java.sql.SQLException- if there is an error processing the XML value. An exception is thrown if the state is not writable.If- there is an error
-
setCharacterStream
public java.io.Writer setCharacterStream() throws java.sql.SQLExceptionRetrieves a Writer to be used to write the XML value that this SQLXML instance represents.- Specified by:
setCharacterStreamin interfacejava.sql.SQLXML- Returns:
- a stream to which data can be written.
- Throws:
java.sql.SQLException- if there is an error processing the XML value. The getCause() method of the exception may provide a more detailed exception, for example, if the stream does not contain valid characters. An exception is thrown if the state is not writable.If- there is an error
-
setResult
public <T extends javax.xml.transform.Result> T setResult(java.lang.Class<T> resultClass) throws java.sql.SQLExceptionReturns a Result for setting the XML value designated by this SQLXML instance.- Specified by:
setResultin interfacejava.sql.SQLXML- Parameters:
resultClass- The class of the result, or null. If resultClass is null, a vendor specific Result implementation will be returned. The following classes are supported at a minimum:javax.xml.transform.dom.DOMResult - returns a DOMResult javax.xml.transform.sax.SAXResult - returns a SAXResult javax.xml.transform.stax.StAXResult - returns a StAXResult javax.xml.transform.stream.StreamResult - returns a StreamResult
- Returns:
- Returns a Result for setting the XML value.
- Throws:
java.sql.SQLException- if there is an error processing the XML value or if this feature is not supported. The getCause() method of the exception may provide a more detailed exception, for example, if an XML parser exception occurs. An exception is thrown if the state is not writable.If- there is an error
-
free
public void free() throws java.sql.SQLExceptionThis method frees the object and releases the the resources that it holds. The object is invalid once thefreemethod is called. Iffreeis called multiple times, the subsequent calls tofreeare treated as a no-op.- Specified by:
freein interfacejava.sql.SQLXML- Throws:
java.sql.SQLException- if an error occurs releasing the Clob's resources
-
-