JDBC provides different classes to support BLOB, CLOB, and XML values.
A BLOB value can be used to store the binary large value. A BLOB object can be created and populated using the way shown in below
Creating a BLOB value
BLOB implementation in DB2 JDBC universal driver does not support any constructor function to create the BLOB object. So, it is not possible to create a BLOB object using a new operator.
The value of the BLOB type parameter can be set using the following PreparedStatement setter methods:
The BLOB value from the ResultSet object can be retrieved using the following ResultSet getter methods:
CLOB and DBCLOB
A CLOB value can be used to store the character large value. A CLOB object can be created using a way similar to the way we created a BLOB object. Example 5-15 shows how to create a CLOB value.
Creating a CLOB value
The parameter value of type CLOB can be set using the following setter methods of PreparedStatement object:
The CLOB value can be retrieved from the result set using the following getter methods of ResultSet object:
DBCLOB values are handled as CLOB objects in JDBC.
GRAPHICS and DBGRAPHICS
GRAPHICS and DBGRAPHICS are treated as String values in JDBC.
XML is a new data type introduced in DB2 9. XML is different from the current data types supported in DB2, because XML is self-defined and stored in an tree structure manner in the database. For more details about the XML data type, refer to Chapter , “Application development with DB2 pureXML”. Currently, JDBC does not have any XML class to support the XML data type. XML data or columns can be mapped to any of the following:
com.ibm.db2.DB2Xml is a newly introduced class in JDBC universal driver. This class is a native class for the universal driver for handling the XML values. The following setXXX method can be used to set the value of the XML parameter in a PreparedStatement object:
Supports DB2Xml, String, byte, inputStream, Reader, CLOB, and BLOB as parameters The encoding conversion of the XML data depends on which setXXX method is used to bind the parameter value. The setAsciiStream, setCharacterStream, and setString methods convert the encoding to UTF-8 and send the XML value as an explicit external encoding; setByte and setBinaryStream assume that the internal encoding is correct and send the XML value with internal encoding.
An XML value can be retrieved from the ResultSet using the following getXXX methods:
The getObject method will retrieve the XML value as an DB2Xml class object. The XML values retrieved by these methods are externally encoded data and without explicit XML declaration. These methods cannot be called on the same XML row again. Trying to do that will throw an SQLException.
DB2 Universal JDBC driver introduces the DB2Xml class. The object of this class is returned to the application whenever the getObject method is used to retrieve the XML column value from the ResultSet object. This class define methods to convert the XML data to other Java data types, such as String, byte, BinaryStream, and AsciiStream. These methods have the getDB2XXX format where XXX indicate the data type. This class also defines the methods which convert the XML data to the specified data and add the XML declaration tag. These methods have a format such as getDB2XmlXXX. Below shows how to retrieve an XML value as a DB2Xml object.
Retrieving XML value as a DB2Xml object
The metadata information regarding the XML data type column gives the data type of the column as java.sql.Types.OTHER because there is no XML data type defined in the JDBC standard.
IBM DB2 Related Interview Questions
|IBM Websphere Interview Questions||IBM-REXX Interview Questions|
|IBM Cognos Interview Questions||IBM DB2 Interview Questions|
|J2EE Interview Questions||COBOL Interview Questions|
|IBM-JCL Interview Questions||DB2 Using SQL Interview Questions|
|IBM WAS Administration Interview Questions||IBM WebSphere Administration Interview Questions|
|Database Administration Interview Questions||DB2 SQL Programming Interview Questions|
|Mainframe DB2 Interview Questions|
IBM DB2 Related Practice Tests
|IBM Websphere Practice Tests||IBM Cognos Practice Tests|
|IBM DB2 Practice Tests||J2EE Practice Tests|
|COBOL Practice Tests||IBM-JCL Practice Tests|
|DB2 Using SQL Practice Tests||IBM WAS Administration Practice Tests|
|Database Administration Practice Tests||DB2 SQL Programming Practice Tests|
Ibm Db2 Tutorial
Db2 Application Development Overview
Application Development With Db2 Purexml
Application Development With Php
Application Development With C/c++
Application Development With Java
Application Development With .net
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.