ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/advancdt.htm

149 lines
10 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Advanced data types" />
<meta name="abstract" content="Advanced SQL3 data types give you a tremendous amount of flexibility. They are ideal for storing serialized Java objects, Extensible Markup Language (XML) documents, and multimedia data such as songs, product pictures, employee photographs, and movie clips. Java Database Connectivity (JDBC) 2.0 and higher provide support for working with these data types that are a part of the SQL99 standard." />
<meta name="description" content="Advanced SQL3 data types give you a tremendous amount of flexibility. They are ideal for storing serialized Java objects, Extensible Markup Language (XML) documents, and multimedia data such as songs, product pictures, employee photographs, and movie clips. Java Database Connectivity (JDBC) 2.0 and higher provide support for working with these data types that are a part of the SQL99 standard." />
<meta name="DC.Relation" scheme="URI" content="jdbc.htm" />
<meta name="DC.Relation" scheme="URI" content="adwrblob.htm" />
<meta name="DC.Relation" scheme="URI" content="adwrclob.htm" />
<meta name="DC.Relation" scheme="URI" content="adwrdlnk.htm" />
<meta name="DC.Relation" scheme="URI" content="distinct.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="advancdt" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Advanced data types</title>
</head>
<body id="advancdt"><a name="advancdt"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Advanced data types</h1>
<div><p>Advanced SQL3 data types give you a tremendous amount of flexibility.
They are ideal for storing serialized Java™ objects, Extensible Markup Language
(XML) documents, and multimedia data such as songs, product pictures, employee
photographs, and movie clips. Java Database Connectivity (JDBC) 2.0 and
higher provide support for working with these data types that are a part of
the SQL99 standard.</p>
<div class="section"><h4 class="sectiontitle">Distinct types</h4><p>The distinct type is a user-defined
type that is based on a standard database type. For example, you can define
a Social Security Number type, SSN, that is a CHAR(9) internally. The following
SQL statement creates such a DISTINCT type. </p>
<blockquote><pre>CREATE DISTINCT TYPE CUJOSQL.SSN AS CHAR(9)</pre>
</blockquote>
<p>A
distinct type always maps to a built-in data type. For more information on
how and when to use distinct types in the context of SQL, consult the SQL
reference manuals.</p>
<p>To use distinct types in JDBC, you access them the
same way that you access an underlying type. The getUDTs method is a new method
that allows you to query what distinct types are available on the system. <a href="distinct.htm#distinct">Example: Distinct types</a> program shows the following:</p>
<ul><li>The creation of a distinct type.</li>
<li>The creation of a table that uses it.</li>
<li>The use of a PreparedStatement to set a distinct type parameter.</li>
<li>The use of a ResultSet to return a distinct type.</li>
<li>The use of the metadata Application Programming Interface (API) call to
getUDTs to learn about a distinct type.</li>
</ul>
<p>For more information, see the following example that shows various
commons tasks you can perform by using distinct types:</p>
<blockquote> <p><a href="distinct.htm#distinct">Example: Distinct types</a></p>
</blockquote>
</div>
<div class="section"><h4 class="sectiontitle">Large Objects</h4><p> There are three types of Large Objects
(LOBs): </p>
<ul><li>Binary Large Objects (BLOBs)</li>
<li>Character Large Objects (CLOBs)</li>
<li>Double Byte Character Large Objects (DBCLOBs)</li>
</ul>
<p> DBCLOBs are similar to CLOBs except for their internal storage representation
of the character data. Because Java and JDBC externalize all character
data as Unicode, there is only support in JDBC for CLOBs. DBCLOBs work interchangeable
with the CLOB support from a JDBC perspective. </p>
</div>
<div class="section"><h4 class="sectiontitle">Binary Large Objects</h4><p>In many ways, a Binary Large
Object (BLOB) column is similar to a CHAR FOR BIT DATA column that can be
made large. You can store anything in these columns that can be represented
as a stream of nontranslated bytes. Often, BLOB columns are used to store
serialized Java objects, pictures, songs, and other binary data.</p>
<p>You
can use BLOBs the same way you can use other standard database
types. You can pass them to stored procedures, use them in prepared statements,
and update them in result sets. The PreparedStatement class has a setBlob
method for passing BLOBs to the database, and the ResultSet class adds a getBlob
class for retrieving them from the database. A BLOB is represented in a Java program
by a BLOB object that is a JDBC interface.</p>
<p>Refer to <a href="adwrblob.htm">Write
code that uses BLOBs</a> for more information about how to use BLOBs.</p>
</div>
<div class="section"><h4 class="sectiontitle">Character Large Objects</h4><p>Character Large Objects
(CLOBs) are the character data complement to BLOBs. Instead of storing data
in the database without translation, the data is stored in the database as
text and is processed the same way as a CHAR column. As with BLOBs, JDBC 2.0
provides functions for dealing directly with CLOBs. The PreparedStatement
interface contains a setClob method and the ResultSet interface contains a
getClob method.</p>
<p>Refer to <a href="adwrclob.htm">Write code that
uses CLOBs</a> for more information about how to use CLOBs.</p>
<p>Although
BLOB and CLOB columns work like CHAR FOR BIT DATA and CHAR columns, this is
conceptually how they work from an external user's perspective. Internally,
they are different; because of the potentially enormous size of Large Object
(LOB) columns, you typically work indirectly with data. For example, when
a block of rows is fetched from the database, you do not move a block of LOBs
to the ResultSet. You move pointers called LOB locators (that is, four-byte
integers) into the ResultSet instead. However, it is not necessary to know
about locators when working with LOBs in JDBC.</p>
</div>
<div class="section"><h4 class="sectiontitle">Datalinks</h4><p><strong>Datalinks</strong> are encapsulated values
that contain a logical reference from the database to a file stored outside
the database. Datalinks are represented and used from a JDBC perspective in
two different ways, depending on whether you are using JDBC 2.0 or earlier,
or you are using JDBC 3.0 or later.</p>
<p>Refer to <a href="adwrdlnk.htm">Write
code that uses Datalinks</a> for more information about how to use Datalinks.</p>
</div>
<div class="section"><h4 class="sectiontitle">Unsupported SQL3 data types</h4><p>There are other SQL3
data types that have been defined and for which the JDBC API provides support.
These are ARRAY, REF, and STRUCT. Presently, iSeries™ servers do not support these
types. Therefore, the JDBC driver does not provide any form of support for
them.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="adwrblob.htm">Write code that uses BLOBs</a></strong><br />
There are a number of tasks that can be accomplished with database
Binary Large Object (BLOB) columns through the Java Database Connectivity (JDBC) Application
Programming Interface (API). The following topics briefly discuss these tasks
and include examples on how to accomplish them.</li>
<li class="ulchildlink"><strong><a href="adwrclob.htm">Write code that uses CLOBs</a></strong><br />
There are a number of tasks that can be performed with database
CLOB and DBCLOB columns through the Java Database Connectivity (JDBC) Application
Programming Interface (API). The following topics briefly discuss these tasks
and include examples on how to accomplish them.</li>
<li class="ulchildlink"><strong><a href="adwrdlnk.htm">Write code that uses Datalinks</a></strong><br />
How you work with Datalinks is dependent on what release you are working with. In JDBC 3.0, there is support to work directly with Datalink columns using the getURL and putURL methods.</li>
<li class="ulchildlink"><strong><a href="distinct.htm">Example: Distinct types</a></strong><br />
This is an example of how to use distinct types.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="jdbc.htm" title="The IBM Developer Kit for Java JDBC driver, also known as the &#34;native&#34; driver, provides programmatic access to iSeries database files. Using the Java Database Connectivity (JDBC) API, applications written in the Java language can access JDBC database functions with embedded Structured Query Language (SQL), run SQL statements, retrieve results, and propagate changes back to the database. The JDBC API can also be used to interact with multiple data sources in a distributed, heterogeneous environment.">Access your iSeries database with the IBM Developer Kit for Java JDBC driver</a></div>
</div>
</div>
</body>
</html>