public class DataTruncation extends SQLWarning
If JDBC unexpectedly truncates a data value during a write, a DataTruncation exception is thrown. If this occurs during a read, a DataTruncation warning is created. The SQLstate value is set to 01004 for a DataTruncation.
DataTruncation
public DataTruncation(int index, boolean parameter, boolean read, int dataSize, int transferSize)
This constructs a DataTruncation object with 01004 as SQLState and Data truncation as reason.
Parameters:
index: | The index of the parameter or column value for which a truncation occurred |
parameter: | true if the truncation occurred when accessing a parameter |
read: | true if the truncation occurred during a database read |
dataSize: | The size of the data before being truncated |
transferSize: | The size after truncation |
getDataSize
public int getDataSize()
This gets the original data length in bytes.
Returns: The DataTruncation’s dataSize value or -1 if unknown
getIndex
public int getIndex()
This gets the index of the column or the parameter that was truncated.
Returns: The DataTruncation’s index value or -1 if unknown
getParameter
public boolean getParameter()
This checks whether the truncation occurred when reading or writing a parameter’s value.
Returns: true if the truncated value was a parameter or false if it was a column
getRead
public boolean getRead()
This checks whether the truncation occurred when reading a parameter or a column.
Returns: true if the value was truncated during a database read or false if the truncation occurred during a database write
getTransferSize
public int getTransferSize()
This gets the number of bytes of data transferred.
Returns: The number of bytes of data transferred or -1 if unknown