Class DataTruncation
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.sql.SQLException
java.sql.SQLWarning
java.sql.DataTruncation
- All Implemented Interfaces:
Serializable, Iterable<Throwable>
An exception thrown as a
DataTruncation exception
(on writes) or reported as a
DataTruncation warning (on reads)
when a data values is unexpectedly truncated for reasons other than its having
exceeded MaxFieldSize.
The SQLstate for a DataTruncation during read is 01004.
The SQLstate for a DataTruncation during write is 22001.
- Since:
- 1.1
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize) Creates aDataTruncationobject with the SQLState initialized to 01004 whenreadis set totrueand 22001 whenreadis set tofalse, the reason set to "Data truncation", the vendor code set to 0, and the other fields set to the given values.DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize, Throwable cause) Creates aDataTruncationobject with the SQLState initialized to 01004 whenreadis set totrueand 22001 whenreadis set tofalse, the reason set to "Data truncation", the vendor code set to 0, and the other fields set to the given values. -
Method Summary
Modifier and TypeMethodDescriptionintGets the number of bytes of data that should have been transferred.intgetIndex()Retrieves the index of the column or parameter that was truncated.booleanIndicates whether the value truncated was a parameter value or a column value.booleangetRead()Indicates whether or not the value was truncated on a read.intGets the number of bytes of data actually transferred.Methods declared in class SQLWarning
getNextWarning, setNextWarningModifier and TypeMethodDescriptionRetrieves the warning chained to thisSQLWarningobject bysetNextWarning.voidAdds aSQLWarningobject to the end of the chain.Methods declared in class SQLException
getErrorCode, getNextException, getSQLState, iterator, setNextExceptionModifier and TypeMethodDescriptionintRetrieves the vendor-specific exception code for thisSQLExceptionobject.Retrieves the exception chained to thisSQLExceptionobject by setNextException(SQLException ex).Retrieves the SQLState for thisSQLExceptionobject.iterator()Returns an iterator over the chained SQLExceptions.voidAdds anSQLExceptionobject to the end of the chain.Methods declared in class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringModifier and TypeMethodDescriptionfinal voidaddSuppressed(Throwable exception) Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.Fills in the execution stack trace.getCause()Returns the cause of this throwable ornullif the cause is nonexistent or unknown.Creates a localized description of this throwable.Returns the detail message string of this throwable.Provides programmatic access to the stack trace information printed byThrowable.printStackTrace().final Throwable[]Returns an array containing all of the exceptions that were suppressed, typically by thetry-with-resources statement, in order to deliver this exception.Initializes the cause of this throwable to the specified value.voidPrints this throwable and its backtrace to the standard error stream.voidPrints this throwable and its backtrace to the specified print stream.voidPrints this throwable and its backtrace to the specified print writer.voidsetStackTrace(StackTraceElement[] stackTrace) Sets the stack trace elements that will be returned byThrowable.getStackTrace()and printed byThrowable.printStackTrace()and related methods.toString()Returns a short description of this throwable.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.Methods declared in interface Iterable
forEach, spliteratorModifier and TypeMethodDescriptiondefault voidPerforms the given action for each element of theIterableuntil all elements have been processed or the action throws an exception.default Spliterator<Throwable> Creates aSpliteratorover the elements described by thisIterable.
-
Constructor Details
-
DataTruncation
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize) Creates aDataTruncationobject with the SQLState initialized to 01004 whenreadis set totrueand 22001 whenreadis set tofalse, the reason set to "Data truncation", the vendor code set to 0, and the other fields set to the given values. Thecauseis not initialized, and may subsequently be initialized by a call to theThrowable.initCause(java.lang.Throwable)method.- Parameters:
index- The index of the parameter or column valueparameter- true if a parameter value was truncatedread- true if a read was truncateddataSize- the original size of the datatransferSize- the size after truncation
-
DataTruncation
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize, Throwable cause) Creates aDataTruncationobject with the SQLState initialized to 01004 whenreadis set totrueand 22001 whenreadis set tofalse, the reason set to "Data truncation", the vendor code set to 0, and the other fields set to the given values.- Parameters:
index- The index of the parameter or column valueparameter- true if a parameter value was truncatedread- true if a read was truncateddataSize- the original size of the datatransferSize- the size after truncationcause- the underlying reason for thisDataTruncation(which is saved for later retrieval by thegetCause()method); may be null indicating the cause is non-existent or unknown.- Since:
- 1.6
-
-
Method Details
-
getIndex
public int getIndex()Retrieves the index of the column or parameter that was truncated.This may be -1 if the column or parameter index is unknown, in which case the
parameterandreadfields should be ignored.- Returns:
- the index of the truncated parameter or column value
-
getParameter
public boolean getParameter()Indicates whether the value truncated was a parameter value or a column value.- Returns:
trueif the value truncated was a parameter;falseif it was a column value
-
getRead
public boolean getRead()Indicates whether or not the value was truncated on a read.- Returns:
trueif the value was truncated when read from the database;falseif the data was truncated on a write
-
getDataSize
public int getDataSize()Gets the number of bytes of data that should have been transferred. This number may be approximate if data conversions were being performed. The value may be-1if the size is unknown.- Returns:
- the number of bytes of data that should have been transferred
-
getTransferSize
public int getTransferSize()Gets the number of bytes of data actually transferred. The value may be-1if the size is unknown.- Returns:
- the number of bytes of data actually transferred
-