100 lines
6.9 KiB
HTML
100 lines
6.9 KiB
HTML
<?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="reference" />
|
|
<meta name="DC.Title" content="AS400JDBCBlob class" />
|
|
<meta name="abstract" content="You can use a AS400JDBCBlob object to access binary large objects (BLOBs), such as sound byte (.wav) files or image (.gif) files." />
|
|
<meta name="description" content="You can use a AS400JDBCBlob object to access binary large objects (BLOBs), such as sound byte (.wav) files or image (.gif) files." />
|
|
<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="jdbblob" />
|
|
<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>AS400JDBCBlob class</title>
|
|
</head>
|
|
<body id="jdbblob"><a name="jdbblob"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">AS400JDBCBlob class</h1>
|
|
<div><p>You can use a AS400JDBCBlob object to access binary large objects
|
|
(BLOBs), such as sound byte (.wav) files or image (.gif) files.</p>
|
|
<div class="section"><p><a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html">AS400JDBCBlob</a> </p>
|
|
<p>The key difference
|
|
between the AS400JDBCBlob class and the AS400JDBCBlobLocator class is where
|
|
the blob is stored. With the AS400JDBCBlob class, the blob is stored in the
|
|
database, which inflates the size of the database file. The AS400JDBCBlobLocator
|
|
class stores a locator (think of it as a pointer) in the database file that
|
|
points to where the blob is located.</p>
|
|
<p>With the AS400JDBCBlob class, the
|
|
lob threshold property can be used. This property specifies the maximum large
|
|
object (LOB) size (in kilobytes) that can be retrieved as part of a result
|
|
set. LOBs that are larger than this threshold are retrieved in pieces using
|
|
extra communication to the server. Larger LOB thresholds reduce the frequency
|
|
of communication to the server, but they download more LOB data, even if it
|
|
is not used. Smaller lob thresholds may increase frequency of communication
|
|
to the server, but they only download LOB data as it is needed. See <a href="jdbcproperties.htm#jdbcproperties">JDBC properties</a> for information
|
|
about additional properties that are available.</p>
|
|
<p>Using the AS400JDBCBlob
|
|
class, you can do the following:</p>
|
|
<ul><li>Return the entire blob as a <a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#GETBINARYSTREAM()">stream of uninterpreted bytes</a></li>
|
|
<li>Return part of the <a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#GETBYTES(LONG, INT)">contents</a> of the blob</li>
|
|
<li>Return the <a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#LENGTH()">length</a> of the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#SETBINARYSTREAM(LONG)">Create a binary stream</a> to write to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#SETBYTES(LONG, BYTE[])">Write a byte array</a> to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#SETBYTES(LONG, BYTE[], INT, INT)">Write all or a portion of byte array</a> to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlob.html#TRUNCATE(LONG)">Truncate</a> the blob</li>
|
|
</ul>
|
|
</div>
|
|
<div class="section" id="jdbblob__blobexamples"><a name="jdbblob__blobexamples"><!-- --></a><h4 class="sectiontitle">Examples</h4><p>The following examples
|
|
show how to use the AS400JDBCBlob class to read from a blob and update a blob:</p>
|
|
</div>
|
|
<div class="section"><p><strong>Example: Using the AS400JDBCBlob class to read from a blob</strong></p>
|
|
<pre> Blob blob = resultSet.getBlob(1);
|
|
long length = blob.length();
|
|
byte[] bytes = blob.getBytes(1, (int) length);</pre>
|
|
<p><strong>Example:
|
|
Using the AS400JDBCBlob class to update a blob</strong></p>
|
|
<pre> ResultSet rs = statement.executeQuery ("SELECT BLOB FROM MYTABLE");
|
|
rs.absolute(5);
|
|
Blob blob = rs.getBlob(1);
|
|
// Change the bytes in the blob, starting at the seventh byte
|
|
// of the blob
|
|
blob.setBytes (7, new byte[] { (byte) 57, (byte) 58, (byte) 98});
|
|
//Update the blob in the result set, changing the blob starting
|
|
// at the seventh byte of the blob (1-based) and truncating the
|
|
// blob at the end of the updated bytes (the blob now has 9 bytes).
|
|
rs.updateBlob(1, blob);
|
|
// Update the database with the change. This will change the blob
|
|
// in the database starting at the seventh byte of the blob, and
|
|
// truncating at the end of the updated bytes.
|
|
rs.updateRow();
|
|
rs.close();</pre>
|
|
</div>
|
|
<div class="section" id="jdbblob__jdbcblobloc"><a name="jdbblob__jdbcblobloc"><!-- --></a><h4 class="sectiontitle">AS400JDBCBlobLocator class</h4><p>You
|
|
can use a <a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#NAVBAR_TOP">AS400JDBCBlobLocator</a> object to access a binary large
|
|
objects.</p>
|
|
<p>Using the AS400JDBCBlobLocator class, you can do the following:</p>
|
|
<ul><li>Return the entire blob as a <a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#GETBINARYSTREAM()">stream of uninterpreted bytes</a></li>
|
|
<li>Return part of the <a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#GETBYTES(LONG, INT)">contents</a> of the blob</li>
|
|
<li>Return the <a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#LENGTH()">length</a> of the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#SETBINARYSTREAM(LONG)">Create a binary stream</a> to write to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#SETBYTES(LONG, BYTE[])">Write a byte array</a> to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#SETBYTES(LONG, BYTE[], INT, INT)">Write all or a portion of byte array</a> to the blob</li>
|
|
<li><a href="javadoc/com/ibm/as400/access/AS400JDBCBlobLocator.html#TRUNCATE(LONG)">Truncate</a> the blob</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |