Class JDBC4MysqlSQLXML
- All Implemented Interfaces:
SQLXML
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJDBC4MysqlSQLXML(ExceptionInterceptor exceptionInterceptor) protectedJDBC4MysqlSQLXML(ResultSetInternalMethods owner, int index, ExceptionInterceptor exceptionInterceptor) -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringvoidfree()Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object.<T extends Source>
TReturns a Source for reading the XML value designated by this SQLXML instance.booleanisEmpty()protected StringreaderToString(Reader reader) protected Readerprotected StringRetrieves a stream that can be used to write the XML value that this SQLXML instance represents.Retrieves a stream to be used to write the XML value that this SQLXML instance represents.<T extends Result>
TReturns a Result for setting the XML value designated by this SQLXML instance.voidSets the XML value designated by this SQLXML instance to the given String representation.
-
Constructor Details
-
JDBC4MysqlSQLXML
protected JDBC4MysqlSQLXML(ResultSetInternalMethods owner, int index, ExceptionInterceptor exceptionInterceptor) -
JDBC4MysqlSQLXML
-
-
Method Details
-
free
- Specified by:
freein interfaceSQLXML- Throws:
SQLException
-
getString
- Specified by:
getStringin interfaceSQLXML- Throws:
SQLException
-
setString
Sets the XML value designated by this SQLXML instance to the given String representation. The format of this String 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 String is unicode. The behavior of this method is the same as ResultSet.updateString() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
- Specified by:
setStringin interfaceSQLXML- Parameters:
value- the XML value- Throws:
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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
isEmpty
- Throws:
SQLException
-
getBinaryStream
- Specified by:
getBinaryStreamin interfaceSQLXML- Throws:
SQLException
-
getCharacterStream
Retrieves 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 interfaceSQLXML- Returns:
- a stream containing the XML data.
- Throws:
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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
getSource
Returns a Source for reading the XML value designated by this SQLXML instance. Sources are used as inputs to XML parsers and XSLT transformers.Sources for XML parsers will have namespace processing on by default. The systemID of the Source is implementation dependent.
The SQL XML object becomes not readable when this method is called and may also become not writable depending on implementation.
Note that SAX is a callback architecture, so a returned SAXSource should then be set with a content handler that will receive the SAX events from parsing. The content handler will receive callbacks based on the contents of the XML.
SAXSource saxSource = sqlxml.getSource(SAXSource.class); XMLReader xmlReader = saxSource.getXMLReader(); xmlReader.setContentHandler(myHandler); xmlReader.parse(saxSource.getInputSource());
- Specified by:
getSourcein interfaceSQLXML- Parameters:
sourceClass- The class of the source, or null. If the class is null, a vendor specifc Source implementation will be returned. The following classes are supported at a minimum: (MySQL returns a SAXSource if sourceClass == null)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:
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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setBinaryStream
Retrieves a stream that can be used to write the XML value that this SQLXML instance represents. The stream begins at position 0. The bytes of the stream are interpreted according to appendix F of the XML 1.0 specification The behavior of this method is the same as ResultSet.updateBinaryStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
- Specified by:
setBinaryStreamin interfaceSQLXML- Returns:
- a stream to which data can be written.
- Throws:
SQLException- if there is an error processing the XML value. An exception is thrown if the state is not writable.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setCharacterStream
Retrieves a stream to be used to write the XML value that this SQLXML instance represents. 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.updateCharacterStream() when the designated column of the ResultSet has a type java.sql.Types of SQLXML.The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
- Specified by:
setCharacterStreamin interfaceSQLXML- Returns:
- a stream to which data can be written.
- Throws:
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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
setResult
Returns a Result for setting the XML value designated by this SQLXML instance.The systemID of the Result is implementation dependent.
The SQL XML object becomes not writeable when this method is called and may also become not readable depending on implementation.
Note that SAX is a callback architecture and the returned SAXResult has a content handler assigned that will receive the SAX events based on the contents of the XML. Call the content handler with the contents of the XML document to assign the values.
SAXResult saxResult = sqlxml.setResult(SAXResult.class); ContentHandler contentHandler = saxResult.getXMLReader().getContentHandler(); contentHandler.startDocument(); // set the XML elements and attributes into the result contentHandler.endDocument();
- Specified by:
setResultin interfaceSQLXML- 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:
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.SQLFeatureNotSupportedException- if the JDBC driver does not support this method- Since:
- 1.6
-
readerToString
- Throws:
SQLException
-
serializeAsCharacterStream
- Throws:
SQLException
-
domSourceToString
- Throws:
SQLException
-
serializeAsString
- Throws:
SQLException
-