org.firebirdsql.jdbc.field
Class FBWorkaroundStringField

java.lang.Object
  extended by org.firebirdsql.jdbc.field.FBField
      extended by org.firebirdsql.jdbc.field.FBStringField
          extended by org.firebirdsql.jdbc.field.FBWorkaroundStringField

public class FBWorkaroundStringField
extends FBStringField

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

Field Summary
 
Fields inherited from class org.firebirdsql.jdbc.field.FBField
field, gdsHelper, iscEncoding, javaEncoding, mappingPath, numCol, requiredType, scale
 
Constructor Summary
FBWorkaroundStringField(XSQLVAR field, FieldDataProvider dataProvider, int requiredType)
          Create instance of this class for the specified field and result set.
 
Method Summary
 String getString()
          Get string value of this field.
 void setConnection(GDSHelper gdsHelper)
          Set connection for this field.
 void setString(String value)
           
 byte[] setStringForced(String value)
          Set string value without any check of its length.
 void setTrimString(boolean trimString)
           
 
Methods inherited from class org.firebirdsql.jdbc.field.FBStringField
getAsciiStream, getBigDecimal, getBinaryStream, getBoolean, getByte, getBytes, getDate, getDate, getDouble, getFloat, getInt, getLong, getShort, getTime, getTime, getTimestamp, getTimestamp, getUnicodeStream, setAsciiStream, setBigDecimal, setBinaryStream, setBoolean, setByte, setBytes, setCharacterStream, setDate, setDate, setDouble, setFloat, setInteger, setLong, setShort, setTime, setTime, setTimestamp, setTimestamp, setUnicodeStream
 
Methods inherited from class org.firebirdsql.jdbc.field.FBField
close, createField, getAlias, getArray, getBigDecimal, getBlob, getCharacterStream, getClob, getFieldData, getName, getObject, getObject, getRef, getRelationName, isCompatible, isInvertTimeZone, isNull, isType, setBlob, setFieldData, setNull, setObject, setRequiredType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FBWorkaroundStringField

public FBWorkaroundStringField(XSQLVAR field,
                               FieldDataProvider dataProvider,
                               int requiredType)
                        throws SQLException
Create instance of this class for the specified field and result set.

Parameters:
field - instance of XSQLVAR containing field value.
dataProvider - data provider for this field
requiredType - required type.
Throws:
SQLException - if something went wrong.
Method Detail

setConnection

public void setConnection(GDSHelper gdsHelper)
Set connection for this field. This method estimates character length and bytes per chracter.

Overrides:
setConnection in class FBField

setTrimString

public void setTrimString(boolean trimString)

setString

public void setString(String value)
               throws SQLException
Overrides:
setString in class FBStringField
Throws:
SQLException

setStringForced

public byte[] setStringForced(String value)
                       throws SQLException
Set string value without any check of its length. This is a workaround for the problem described above.

Parameters:
value - value to set.
Throws:
SQLException - if something went wrong.

getString

public String getString()
                 throws SQLException
Get string value of this field.

Overrides:
getString in class FBStringField
Returns:
string value of this filed or null if the value is NULL.
Throws:
SQLException


Copyright © 2001-2010. All Rights Reserved.