Returning XML Data
- Last Updated: May 15, 2020
- 1 minute read
- DataDirect Connectors
- JDBC
- IBM Db2 5.1
- MySQL 5.1
- Progress OpenEdge 5.1
- SAP Sybase 5.1
- Documentation
The driver can return XML data as character data. For example, given a database table defined as:
CREATE TABLE xmlTable (id int, xmlCol XMLType NOT NULL)
the driver can return the XML data as character data using the following code:
String sql="SELECT xmlCol FROM xmlTable";
ResultSet rs=stmt.executeQuery(sql)
String charXML=rs.getString(1)
The result set column is described with a column type of CLOB and the column type name is xmlType.
Your application can use the following methods to return data stored in XML columns as character data:
- ResultSet.getString()
- ResultSet.getCharacterStream()
- ResultSet.getClob()
- CallableStatement.getString()
- CallableStatement.getClob()
The driver converts the XML data returned from the database server from the character set encoding used by the database server to the UTF-16 Java String encoding.
Your application can use the following method to return data stored in XML columns as ASCII data:
ResultSet.getAsciiStream()
The driver converts the XML data returned from the database server from the character set encoding used by the database server to the ISO-8859-1 (latin1) encoding.