db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chaa...@apache.org
Subject svn commit: r1576358 - in /db/derby/docs/trunk/src: devguide/cdevconcepts844813.dita devguide/rdevprocsqle.dita getstart/rwwdactivity3.dita
Date Tue, 11 Mar 2014 14:13:01 GMT
Author: chaase3
Date: Tue Mar 11 14:13:00 2014
New Revision: 1576358

URL: http://svn.apache.org/r1576358
Log:
DERBY-1997  Misleading text in WwdEmbedded demo source file for Working With Derby

Modified two Developer's Guide topics and one Getting Started topic.

Patch: DERBY-1997-doc.diff

Modified:
    db/derby/docs/trunk/src/devguide/cdevconcepts844813.dita
    db/derby/docs/trunk/src/devguide/rdevprocsqle.dita
    db/derby/docs/trunk/src/getstart/rwwdactivity3.dita

Modified: db/derby/docs/trunk/src/devguide/cdevconcepts844813.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/cdevconcepts844813.dita?rev=1576358&r1=1576357&r2=1576358&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/cdevconcepts844813.dita (original)
+++ db/derby/docs/trunk/src/devguide/cdevconcepts844813.dita Tue Mar 11 14:13:00 2014
@@ -27,14 +27,19 @@ the message, <i>SQLState</i> values, and
 <indexterm>SQL exceptions<indexterm>processing</indexterm></indexterm></keywords>
 </metadata></prolog>
 <conbody>
-<p>Use the <codeph><i>getSQLState</i></codeph> and <codeph><i>getMessage</i></codeph>
methods
-to view the <codeph><i>SQLState</i></codeph> and error messages.
Use <codeph><i>getErrorCode</i></codeph> to
-see the error code. The error code defines the severity of the error and is
-not unique to each exception. <note>Severity is not standardized in <ph conref="../conrefs.dita#prod/productshortname"></ph>.
-Applications should not depend on the severity returned from SQL exceptions.</note></p>
-<p>Applications should also check for and process <i>java.sql.SQLWarnings</i>,
-which are processed in a similar way. <ph conref="../conrefs.dita#prod/productshortname"></ph>
issues
-an <codeph><i>SQLWarning</i></codeph> if the <codeph><i>create=true</i></codeph>
attribute
-is specified and the database already exists.</p>
+<p>You can use methods of <i>java.lang.Throwable</i> to view the message
+issued by a SQL exception, including the <i>SQLState</i> and error messages.</p>
+<p>Alternatively, you can use the <i>getSQLState</i> and <i>getMessage</i>
+methods to view the <i>SQLState</i> and error messages, and you can use
+<i>getErrorCode</i> to see the error code. The error code defines the severity
+of the error and is not unique to each exception.
+<note>Severity is not standardized in
+<ph conref="../conrefs.dita#prod/productshortname"></ph>. Applications should
+not depend on the severity returned from SQL exceptions.</note></p>
+<p>Applications should also check for and process <i>java.sql.SQLWarning</i>s,
+which are processed in a similar way.
+<ph conref="../conrefs.dita#prod/productshortname"></ph> issues an
+<i>SQLWarning</i> if the <i>create=true</i> attribute is specified
and the
+database already exists.</p>
 </conbody>
 </concept>

Modified: db/derby/docs/trunk/src/devguide/rdevprocsqle.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/devguide/rdevprocsqle.dita?rev=1576358&r1=1576357&r2=1576358&view=diff
==============================================================================
--- db/derby/docs/trunk/src/devguide/rdevprocsqle.dita (original)
+++ db/derby/docs/trunk/src/devguide/rdevprocsqle.dita Tue Mar 11 14:13:00 2014
@@ -21,22 +21,31 @@ limitations under the License.
 <reference id="rdevprocsqle" xml:lang="en-us">
 <title>Example of processing SQLExceptions</title>
 <shortdesc>A single error can generate more than one <i>SQLException</i>.
-Use a loop and the <codeph><i>getNextException</i></codeph> method
to process
-all <codeph><i>SQLExceptions</i></codeph> in the chain. In many cases,
the
-second exception in the chain is the pertinent one.</shortdesc>
+Usually, but not always, a call to the <i>printStackTrace</i> method displays
+all these exceptions.</shortdesc>
 <prolog></prolog>
 <refbody>
-<section><p>The following is an example:</p></section>
-<example> <codeblock>catch (Throwable e) {
-    System.out.println("exception thrown:");
-    errorPrint(e);
+<section>
+<p>To ensure that all exceptions are displayed, use a loop and the
+<i>getNextException</i> method to process all <i>SQLException</i>s
in the chain.
+In many cases, the second exception in the chain is the pertinent one.</p>
+<p>The following is an example:</p></section>
+<example>
+<codeblock>        ...
+    } catch (Throwable e) {
+        System.out.println("exception thrown:");
+        errorPrint(e);
+    }
+    ...
 }
+
 static void errorPrint(Throwable e) {
     if (e instanceof SQLException) 
         SQLExceptionPrint((SQLException)e);
     else
         System.out.println("A non-SQL error: " + e.toString());
 }
+
 static void SQLExceptionPrint(SQLException sqle) {
     while (sqle != null) {
         System.out.println("\n---SQLException Caught---\n");
@@ -48,11 +57,11 @@ static void SQLExceptionPrint(SQLExcepti
     }
 }</codeblock></example>
 <section>
-<p>The <i>SQLException</i>
-may wrap another, triggering exception, like an <i>IOException</i>. To inspect
-this additional, wrapped error, call the <i>SQLException</i>'s <i>getCause</i>
method.
-</p></section>
-<section><p>See also "<ph conref="../conrefs.dita#prod/productshortname"></ph>
Exception
-Messages and SQL States", in the <cite><ph conref="../conrefs.dita#pub/citref"></ph></cite>.</p></section>
+<p>The <i>SQLException</i> may wrap another, triggering exception, such
as an
+<i>IOException</i>. To inspect this additional, wrapped error, call the
+<i>SQLException</i>'s <i>getCause</i> method.</p></section>
+<section><p>See also "<ph conref="../conrefs.dita#prod/productshortname"></ph>
+exception messages and SQL states" in the
+<ph conref="../conrefs.dita#pub/citref"></ph>.</p></section>
 </refbody>
 </reference>

Modified: db/derby/docs/trunk/src/getstart/rwwdactivity3.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/getstart/rwwdactivity3.dita?rev=1576358&r1=1576357&r2=1576358&view=diff
==============================================================================
--- db/derby/docs/trunk/src/getstart/rwwdactivity3.dita (original)
+++ db/derby/docs/trunk/src/getstart/rwwdactivity3.dita Tue Mar 11 14:13:00 2014
@@ -163,42 +163,19 @@ the 08006 error (successful shutdown of 
 thrown by <ph conref="../conrefs.dita#prod/productshortname"></ph> that might
 indicate that an operation succeeded. All other exceptions indicate that an
 operation failed. You should check the log file to be certain.</note></section>
-<section><title>The errorPrint and SQLExceptionPrint methods</title><p><cite>DERBY
-EXCEPTION REPORTING CLASSES</cite>: The two methods at the end of the file, <codeph>errorPrint</codeph>
and <codeph>SQLExceptionPrint</codeph>,
-are generic exception-reporting methods that can be used with any JDBC program.
-This type of exception handling is required because often multiple exceptions
-(<codeph>SQLException</codeph>) are chained together and then thrown. A <codeph>while</codeph>
loop
-is used to report on each error in the chain. The  program starts this process
-by calling the <codeph>errorPrint</codeph> method from the <codeph>catch</codeph>
block
-of the code that accesses the database.</p> <codeblock>//  Beginning of the primary
catch block: uses errorPrint method
+<section><title>Handle errors</title><p>
+The <codeph>catch</codeph> block at the end of the program calls the
+<codeph>Throwable.printStackTrace</codeph> method to display the chain of
+exceptions that are thrown if a problem occurs.</p>
+<codeblock>//  Beginning of the primary catch block: prints stack trace
 }  catch (Throwable e)  {   
-   /*    Catch all exceptions and pass them to 
-   **    the exception reporting method   */ 
+    /*    Catch all exceptions and pass them to 
+     *    the Throwable.printStackTrace method  */ 
    System.out.println(" . . . exception thrown:");
-   errorPrint(e);
-}</codeblock><p>The <codeph>errorPrint</codeph> method prints a stack
trace
-for all exceptions except a <codeph>SQLException</codeph>. Each <codeph>SQLException</codeph>
is
-passed to the  <codeph>SQLExceptionPrint</codeph> method.</p><codeblock>static
void errorPrint(Throwable e) {
-   if (e instanceof SQLException) 
-      SQLExceptionPrint((SQLException)e);
-   else {
-      System.out.println("A non SQL error occured.");
-      e.printStackTrace();
-   }   
-}  // END errorPrint </codeblock> <p>The <codeph>SQLExceptionPrint</codeph>
method
-iterates through each of the exceptions on the stack. For each error, the
-method displays the codes, message, and stacktrace.</p> <codeblock>//  Iterates
through a stack of SQLExceptions 
-static void SQLExceptionPrint(SQLException sqle) {
-   while (sqle != null) {
-      System.out.println("\n---SQLException Caught---\n");
-      System.out.println("SQLState:   " + (sqle).getSQLState());
-      System.out.println("Severity: " + (sqle).getErrorCode());
-      System.out.println("Message:  " + (sqle).getMessage()); 
-      sqle.printStackTrace();  
-      sqle = sqle.getNextException();
-   }
-}  //  END SQLExceptionPrint</codeblock> <p>To see the output produced by
-this method, type a wish-list item with more  than 32 characters, such as <userinput>I
-wish to see a Java program fail</userinput>.</p> </section>
+   e.printStackTrace(System.out);
+}</codeblock>
+<p>To view the error output, type a wish-list item with more than 32 characters,
+such as <userinput>I wish to see a Java program fail</userinput>.</p>
+</section>
 </refbody>
 </reference>



Mime
View raw message