Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Designing Java Applications > Handling errors and warnings in JDBC a...

Handling errors and warnings in JDBC applications

A Java application uses its own way of catching exceptions. An error is commonly referred to as an exception in Java applications. An exception can be recognized by an exception class. A try block can have multiple catch blocks. The idea is to handle every possibility of the error condition. JDBC also provides some standard exception classes that can be used to capture the basic information. Apart from them, DB2 also provides its own exception classes that can be used for better diagnosis. In this recipe, we will focus on exception handling in Java applications.

Getting ready

JDBC applications use try and catch blocks to handle different exceptions. There is no exception thrown in the case of warnings. To handle warnings in JDBC applications, we need to explicitly check for warnings. We can use the getWarning() method to retrieve warnings as a SQLWarning object that has the following information:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial