Package java.sql
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>
public class DataTruncation extends SQLWarning implements Serializable
An exception which is thrown when a JDBC driver unexpectedly truncates a data
value either when reading (resulting in warning), or when writing data
(resulting in an error). The
SQLState error code for truncated data
is 01004.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize)Creates theDataTruncationobject.DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize, Throwable cause)Creates a DataTruncation. -
Method Summary
Modifier and Type Method Description intgetDataSize()Gets the number of bytes of data that should have been read/written.intgetIndex()Gets the index of the column or of the parameter that was truncated.booleangetParameter()Gets whether the value truncated was a parameter value or a column value.booleangetRead()Gets whether the value was truncated on a read operation or a write operationintgetTransferSize()Gets the number of bytes of data that was actually read or written.Methods inherited from class java.sql.SQLWarning
getNextWarning, setNextWarningMethods inherited from class java.sql.SQLException
getErrorCode, getNextException, getSQLState, iterator, setNextExceptionMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
DataTruncation
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize)Creates theDataTruncationobject. The reason is set to"Data truncation", the error code is set to theSQLExceptiondefault value, and the other fields are set to the values supplied as arguments.- Parameters:
index- the Index value of the column value or parameter that was truncated.parameter-trueif it was a parameter value that was truncated,falseotherwise.read-trueif the truncation occurred on a read operation,falseotherwise.dataSize- the original size of the truncated data.transferSize- the size of the data after truncation.
-
DataTruncation
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize, Throwable cause)Creates a DataTruncation. The Reason is set to "Data truncation", the error code is set to the SQLException default value and other fields are set to the values supplied on this method.- Parameters:
index- the Index value of the column value or parameter that was truncatedparameter- true if it was a Parameter value that was truncated, false otherwiseread- true if the truncation occurred on a read operation, false otherwisedataSize- the original size of the truncated datatransferSize- the size of the data after truncationcause- the root reason for this DataTruncation- Since:
- 1.6
-
-
Method Details
-
getDataSize
public int getDataSize()Gets the number of bytes of data that should have been read/written.- Returns:
- the number of bytes that should have been read or written. The
value is set to
-1if the size is unknown.
-
getIndex
public int getIndex()Gets the index of the column or of the parameter that was truncated.- Returns:
- the index number of the column or of the parameter.
-
getParameter
public boolean getParameter()Gets whether the value truncated was a parameter value or a column value.- Returns:
trueif the value truncated was a parameter value,falseif it was a column value.
-
getRead
public boolean getRead()Gets whether the value was truncated on a read operation or a write operation- Returns:
trueif the value was truncated on a read operation,falseotherwise.
-
getTransferSize
public int getTransferSize()Gets the number of bytes of data that was actually read or written.- Returns:
- the number of bytes actually read/written. The value may be set
to
-1if the size is unknown.
-