Package org.firebirdsql.jdbc.field
Class FBWorkaroundStringField
- java.lang.Object
-
- org.firebirdsql.jdbc.field.FBField
-
- org.firebirdsql.jdbc.field.FBWorkaroundStringField
-
public final class FBWorkaroundStringField extends FBField
Class implementing workaround for "operation was cancelled" bug in server. When we send some string data exceeding maximum length of the corresponding field causes "operation was cancelled" in remote module of the server instead of "arithmetic exception..." error. This makes code debugging harder, since error message is not very informative.However we cannot simply check length locally. Maximum allowed length in bytes is connected with the character set of the field as defined lengh * maximum number of bytes per character in that encoding. However this does not work for system tables which have defined length 31, character set UNICODE_FSS and maximum allowed length of 31 (instead of 31 * 3 = 63).
Until this bug is fixed in the engine we will simply check if field belongs to the system table and do not throw data truncation error locally.
- Author:
- Roman Rokytskyy, Mark Rotteveel
-
-
Field Summary
Fields Modifier and Type Field Description protected intpossibleCharLength-
Fields inherited from class org.firebirdsql.jdbc.field.FBField
fieldDescriptor, gdsHelper, requiredType, scale
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalgetBigDecimal()java.math.BigIntegergetBigInteger()java.io.InputStreamgetBinaryStream()booleangetBoolean()bytegetByte()byte[]getBytes()java.sql.DategetDate()java.sql.DategetDate(java.util.Calendar cal)doublegetDouble()floatgetFloat()intgetInt()longgetLong()shortgetShort()java.lang.StringgetString()Get string value of this field.java.sql.TimegetTime()java.sql.TimegetTime(java.util.Calendar cal)java.sql.TimestampgetTimestamp()java.sql.TimestampgetTimestamp(java.util.Calendar cal)voidsetBigDecimal(java.math.BigDecimal value)voidsetBigInteger(java.math.BigInteger value)protected voidsetBinaryStreamInternal(java.io.InputStream in, long length)voidsetBoolean(boolean value)voidsetByte(byte value)voidsetBytes(byte[] value)protected voidsetCharacterStreamInternal(java.io.Reader in, long length)voidsetDate(java.sql.Date value)voidsetDate(java.sql.Date value, java.util.Calendar cal)voidsetDouble(double value)voidsetFloat(float value)voidsetInteger(int value)voidsetLong(long value)voidsetShort(short value)voidsetString(java.lang.String value)voidsetStringForced(java.lang.String value)Set string value without any check of its length.voidsetTime(java.sql.Time value)voidsetTime(java.sql.Time value, java.util.Calendar cal)voidsetTimestamp(java.sql.Timestamp value)voidsetTimestamp(java.sql.Timestamp value, java.util.Calendar cal)voidsetTrimString(boolean trimString)-
Methods inherited from class org.firebirdsql.jdbc.field.FBField
close, createField, getAlias, getArray, getBigDecimal, getBlob, getCharacterStream, getClob, getDatatypeCoder, getDecimal, getDecimal, getFieldData, getName, getObject, getObject, getObject, getObjectConverter, getRawDateTimeStruct, getRef, getRelationName, getRowId, isInvertTimeZone, isNull, isType, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setConnection, setDecimal, setFieldData, setNull, setObject, setRawDateTimeStruct, setRequiredType, setRowId
-
-
-
-
Method Detail
-
setTrimString
public void setTrimString(boolean trimString)
-
setString
public void setString(java.lang.String value) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setStringForced
public void setStringForced(java.lang.String value) throws java.sql.SQLExceptionSet string value without any check of its length. This is a workaround for the problem described above.- Parameters:
value- value to set.- Throws:
java.sql.SQLException- if something went wrong.
-
getString
public java.lang.String getString() throws java.sql.SQLExceptionGet string value of this field.- Returns:
- string value of this filed or
nullif the value is NULL. - Throws:
java.sql.SQLException
-
getByte
public byte getByte() throws java.sql.SQLException
-
getShort
public short getShort() throws java.sql.SQLException
-
getInt
public int getInt() throws java.sql.SQLException
-
getLong
public long getLong() throws java.sql.SQLException
-
getBigDecimal
public java.math.BigDecimal getBigDecimal() throws java.sql.SQLException- Overrides:
getBigDecimalin classFBField- Throws:
java.sql.SQLException
-
getFloat
public float getFloat() throws java.sql.SQLException
-
getDouble
public double getDouble() throws java.sql.SQLException
-
getBoolean
public boolean getBoolean() throws java.sql.SQLException- Overrides:
getBooleanin classFBField- Throws:
java.sql.SQLException
-
getBinaryStream
public java.io.InputStream getBinaryStream() throws java.sql.SQLException- Overrides:
getBinaryStreamin classFBField- Throws:
java.sql.SQLException
-
getBytes
public byte[] getBytes() throws java.sql.SQLException
-
getDate
public java.sql.Date getDate(java.util.Calendar cal) throws java.sql.SQLException
-
getDate
public java.sql.Date getDate() throws java.sql.SQLException
-
getTime
public java.sql.Time getTime(java.util.Calendar cal) throws java.sql.SQLException
-
getTime
public java.sql.Time getTime() throws java.sql.SQLException
-
getTimestamp
public java.sql.Timestamp getTimestamp(java.util.Calendar cal) throws java.sql.SQLException- Overrides:
getTimestampin classFBField- Throws:
java.sql.SQLException
-
getTimestamp
public java.sql.Timestamp getTimestamp() throws java.sql.SQLException- Overrides:
getTimestampin classFBField- Throws:
java.sql.SQLException
-
getBigInteger
public java.math.BigInteger getBigInteger() throws java.sql.SQLException- Overrides:
getBigIntegerin classFBField- Throws:
java.sql.SQLException
-
setByte
public void setByte(byte value) throws java.sql.SQLException
-
setShort
public void setShort(short value) throws java.sql.SQLException
-
setInteger
public void setInteger(int value) throws java.sql.SQLException- Overrides:
setIntegerin classFBField- Throws:
java.sql.SQLException
-
setLong
public void setLong(long value) throws java.sql.SQLException
-
setFloat
public void setFloat(float value) throws java.sql.SQLException
-
setDouble
public void setDouble(double value) throws java.sql.SQLException
-
setBigDecimal
public void setBigDecimal(java.math.BigDecimal value) throws java.sql.SQLException- Overrides:
setBigDecimalin classFBField- Throws:
java.sql.SQLException
-
setBoolean
public void setBoolean(boolean value) throws java.sql.SQLException- Overrides:
setBooleanin classFBField- Throws:
java.sql.SQLException
-
setBinaryStreamInternal
protected void setBinaryStreamInternal(java.io.InputStream in, long length) throws java.sql.SQLException- Overrides:
setBinaryStreamInternalin classFBField- Throws:
java.sql.SQLException
-
setCharacterStreamInternal
protected void setCharacterStreamInternal(java.io.Reader in, long length) throws java.sql.SQLException- Overrides:
setCharacterStreamInternalin classFBField- Throws:
java.sql.SQLException
-
setBytes
public void setBytes(byte[] value) throws java.sql.SQLException
-
setDate
public void setDate(java.sql.Date value, java.util.Calendar cal) throws java.sql.SQLException
-
setDate
public void setDate(java.sql.Date value) throws java.sql.SQLException
-
setTime
public void setTime(java.sql.Time value, java.util.Calendar cal) throws java.sql.SQLException
-
setTime
public void setTime(java.sql.Time value) throws java.sql.SQLException
-
setTimestamp
public void setTimestamp(java.sql.Timestamp value, java.util.Calendar cal) throws java.sql.SQLException- Overrides:
setTimestampin classFBField- Throws:
java.sql.SQLException
-
setTimestamp
public void setTimestamp(java.sql.Timestamp value) throws java.sql.SQLException- Overrides:
setTimestampin classFBField- Throws:
java.sql.SQLException
-
setBigInteger
public void setBigInteger(java.math.BigInteger value) throws java.sql.SQLException- Overrides:
setBigIntegerin classFBField- Throws:
java.sql.SQLException
-
-