91 lines
6.1 KiB
HTML
91 lines
6.1 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="concept" />
|
||
|
<meta name="DC.Title" content="SQLWarning" />
|
||
|
<meta name="abstract" content="Methods in some interfaces generate an SQLWarning object if the methods cause a database access warning." />
|
||
|
<meta name="description" content="Methods in some interfaces generate an SQLWarning object if the methods cause a database access warning." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="exceptin.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="exceptions.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="datatruk.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="sqlwarng" />
|
||
|
<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>SQLWarning</title>
|
||
|
</head>
|
||
|
<body id="sqlwarng"><a name="sqlwarng"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">SQLWarning</h1>
|
||
|
<div><p>Methods in some interfaces generate an SQLWarning object if the
|
||
|
methods cause a database access warning.</p>
|
||
|
<p>Methods in the following interfaces can generate an SQLWarning:</p>
|
||
|
<ul><li>Connection</li>
|
||
|
<li>Statement and its subtypes, PreparedStatement and CallableStatement</li>
|
||
|
<li>ResultSet</li>
|
||
|
</ul>
|
||
|
<p> When a method generates an SQLWarning object, the caller is not informed
|
||
|
that a data access warning has occurred. The getWarnings method must be called
|
||
|
on the appropriate object to retrieve the SQLWarning object. However, the
|
||
|
DataTruncation subclass of SQLWarning may be thrown in some circumstances.
|
||
|
It should be noted that the native JDBC driver opts to ignore some database-generated
|
||
|
warnings for increased efficiency. For example, a warning is generated by
|
||
|
the system when you attempt to retrieve data beyond the end of a ResultSet
|
||
|
through the ResultSet.next method. In this case, the next method is defined
|
||
|
to return false instead of true, informing you of the error. It is unnecessary
|
||
|
to create an object to restate this, so the warning is simply ignored. </p>
|
||
|
<p>If multiple data access warnings occur, they are chained to the first one
|
||
|
and can be retrieved by calling the SQLWarning.getNextWarning method. If there
|
||
|
are no more warnings in the chain, getNextWarning returns <samp class="codeph">null</samp>.</p>
|
||
|
<p>Subsequent SQLWarning objects continue to be added to the chain until the
|
||
|
next statement is processed or, in the case of a ResultSet object, when the
|
||
|
cursor is repositioned. As a result, all SQLWarning objects in the chain are
|
||
|
removed.</p>
|
||
|
<p>Using Connection, Statement, and ResultSet objects can cause SQLWarnings
|
||
|
to be generated. SQLWarnings are informational messages indicating that while
|
||
|
a particular operation has completed successfully, there might be other information
|
||
|
of which you should be aware. SQLWarnings are an extension of the SQLException
|
||
|
class, but they are not thrown. They are instead attached to the object that
|
||
|
causes their generation. When an SQLWarning is generated, nothing happens
|
||
|
to inform the application that the warning has been generated. Your application
|
||
|
must actively request warning information.</p>
|
||
|
<p>Like SQLExceptions, SQLWarnings can be chained to one another. You can
|
||
|
call the clearWarnings method on a Connection, Statement, or ResultSet object
|
||
|
to clear the warnings for that object.</p>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Calling the clearWarnings method does not clear all warnings. It only
|
||
|
clears the warnings that are associated with a particular object.</div>
|
||
|
<p>The JDBC driver clears SQLWarning objects at specific times
|
||
|
if you do not clear them manually. SQLWarning objects are cleared when the
|
||
|
following actions are taken:</p>
|
||
|
<ul><li>For the Connection interface, warnings are cleared on the creation of
|
||
|
a new Statement, PreparedStatement, or CallableStatement object.</li>
|
||
|
<li>For the Statement interface, warnings are cleared when the next statement
|
||
|
is processed (or when the statement is processed again for PreparedStatements
|
||
|
and CallableStatements).</li>
|
||
|
<li>For the ResultSet interface, warnings are cleared when the cursor is repositioned. </li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="exceptin.htm" title="The Java language uses exceptions to provide error-handling capabilities for its programs. An exception is an event that occurs when you run your program that disrupts the normal flow of instructions.">Exceptions</a></div>
|
||
|
</div>
|
||
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
||
|
<div><a href="exceptions.htm" title="The SQLException class and its subtypes provide information about errors and warnings that occur while a data source is being accessed.">SQLException</a></div>
|
||
|
<div><a href="datatruk.htm" title="DataTruncation is a subclass of SQLWarning. While SQLWarnings are not thrown, DataTruncation objects are sometimes thrown and attached like other SQLWarning objects. Silent truncation occurs when the size of a column exceeds the size specified by the setMaxFieldSize statement method, but no warning or exception is reported.">DataTruncation and silent truncation</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|