Databases Reference
In-Depth Information
the value to the specified size and a DataTruncation object is created to provide
the information. Whenever truncation happens while reading the value from the
database, an SQLWarning object is created instead of DataTruncation. A
DataTruncation object is created when truncation occurred during writing to the
database.
All the methods in SQLException and SQLWarning classes are inherited in this
class. Apart from these, the following methods give more information regarding
DataTruncation Exception:
getParameter
This method returns true if the parameter value is truncated. It returns false
if the column value is truncated.
getIndex
This method will return an integer value, which gives the index of the
parameter or column being truncated. This method will return -1 if the index
of the column or parameter is unknown.
getRead
This method will return true if the truncation occurs while reading. False is
returned if truncation occurred while writing to the database.
getDataSize
This methods returns the actual size of the data, which should be read or
written to the database without truncation.
getTransferSize
This method will return the size of the data, which is actually read or written to
the database with truncation.
5.9.4 BatchUpdateException
An object of BatchUpdateException is thrown whenever an error occurs while
running a set of statements together by using BatchUpdate. This class inherits all
the methods from java.lang.Exception class. Apart from that, the following
method is provided by the BatchUpdateException for the additional information:
getUpdateCounts:
This method returns a array whose size is equal to the number of elements in
the batch. This array has an entry for each statement in the batch to indicate
the failure or success of the statement.
Example 5-21 on page 233 shows the catch block of the method createCart
from our application example. This method does the batch update to update
the cart table.
Search WWH ::




Custom Search