From: <mro...@us...> - 2012-10-21 08:13:15
|
Revision: 57254 http://firebird.svn.sourceforge.net/firebird/?rev=57254&view=rev Author: mrotteveel Date: 2012-10-21 08:13:07 +0000 (Sun, 21 Oct 2012) Log Message: ----------- Replace calls to fillInStackTrace() after call to factory method for exception creation in favour of direct instantiation of exception (+ cleanup of FBField) Modified Paths: -------------- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBigDecimalField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBlobField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBDoubleField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBFloatField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBIntegerField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBLongField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBLongVarCharField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBNullField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBShortField.java client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBStringField.java Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBigDecimalField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBigDecimalField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBigDecimalField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -66,8 +66,7 @@ // check if value is within bounds if (longValue > MAX_BYTE_VALUE || longValue < MIN_BYTE_VALUE) - throw (SQLException)createException( - BYTE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(BYTE_CONVERSION_ERROR); return (byte)longValue; @@ -99,8 +98,7 @@ // check if value is within bounds if (longValue > MAX_INT_VALUE || longValue < MIN_INT_VALUE) - throw (SQLException)createException( - INT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(INT_CONVERSION_ERROR); return (int)longValue; } @@ -128,8 +126,7 @@ // check if value is within bounds if (longValue > MAX_SHORT_VALUE || longValue < MIN_SHORT_VALUE) - throw (SQLException)createException( - SHORT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(SHORT_CONVERSION_ERROR); return (short)longValue; } @@ -188,8 +185,7 @@ try { setBigDecimal(new BigDecimal(value)); } catch(NumberFormatException nex) { - throw (SQLException)createException( - STRING_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(STRING_CONVERSION_ERROR); } } @@ -219,7 +215,7 @@ protected byte[] encode(final XSQLVAR field, final BigDecimal value) throws SQLException { BigInteger unscaledValue = normalize(value, -field.sqlscale); if (unscaledValue.compareTo(MAX_SHORT) > 0 || unscaledValue.compareTo(MIN_SHORT) < 0) { - throw (SQLException)createException(BIGDECIMAL_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(BIGDECIMAL_CONVERSION_ERROR); } return field.encodeShort(unscaledValue.shortValue()); } @@ -235,7 +231,7 @@ protected byte[] encode(final XSQLVAR field, final BigDecimal value) throws SQLException { BigInteger unscaledValue = normalize(value, -field.sqlscale); if (unscaledValue.compareTo(MAX_INT) > 0 || unscaledValue.compareTo(MIN_INT) < 0) { - throw (SQLException)createException(BIGDECIMAL_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(BIGDECIMAL_CONVERSION_ERROR); } return field.encodeInt(unscaledValue.intValue()); } @@ -251,7 +247,7 @@ protected byte[] encode(final XSQLVAR field, final BigDecimal value) throws SQLException { BigInteger unscaledValue = normalize(value, -field.sqlscale); if (unscaledValue.compareTo(MAX_LONG) > 0 || unscaledValue.compareTo(MIN_LONG) < 0) { - throw (SQLException)createException(BIGDECIMAL_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(BIGDECIMAL_CONVERSION_ERROR); } return field.encodeLong(unscaledValue.longValue()); } Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBlobField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBlobField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBBlobField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -99,8 +99,7 @@ public InputStream getBinaryStream() throws SQLException { // getBinaryStream() is not defined for BLOB types, only for BINARY if (field.sqlsubtype < 0) - throw (SQLException)createException( - BINARY_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(BINARY_STREAM_CONVERSION_ERROR); Blob blob = getBlob(); @@ -148,7 +147,7 @@ if (segementBuffer.length == 0) { // unexpected EOF - throw (SQLException) createException(BYTES_CONVERSION_ERROR); + throw new TypeConversionException(BYTES_CONVERSION_ERROR); } System.arraycopy(segementBuffer, 0, resultBuffer, offset, segementBuffer.length); @@ -198,8 +197,7 @@ public String getString() throws SQLException { // getString() is not defined for BLOB fields, only for BINARY if (field.sqlsubtype < 0) - throw (SQLException)createException( - STRING_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(STRING_CONVERSION_ERROR); Blob blob = getBlob(); Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBDoubleField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBDoubleField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBDoubleField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -48,8 +48,7 @@ // check if value is within bounds if (value > MAX_BYTE_VALUE || value < MIN_BYTE_VALUE) - throw (SQLException)createException( - BYTE_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(BYTE_CONVERSION_ERROR + " " + value); return (byte) value; } @@ -62,8 +61,7 @@ // check if value is within bounds if (value > MAX_SHORT_VALUE || value < MIN_SHORT_VALUE) - throw (SQLException)createException( - SHORT_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(SHORT_CONVERSION_ERROR + " " + value); return (short) value; } @@ -76,8 +74,7 @@ // check if value is within bounds if (value > MAX_INT_VALUE || value < MIN_INT_VALUE) - throw (SQLException)createException( - INT_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(INT_CONVERSION_ERROR + " " + value); return (int) value; } @@ -90,8 +87,7 @@ // check if value is within bounds if (value > MAX_LONG_VALUE || value < MIN_LONG_VALUE) - throw (SQLException)createException( - LONG_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(LONG_CONVERSION_ERROR + " " + value); return (long) value; } @@ -105,8 +101,7 @@ // check if value is within bounds if (cValue == Float.POSITIVE_INFINITY || cValue == Float.NEGATIVE_INFINITY) - throw (SQLException)createException( - FLOAT_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(FLOAT_CONVERSION_ERROR + " " + value); return cValue; } @@ -169,8 +164,7 @@ try { setDouble(Double.parseDouble(value)); } catch(NumberFormatException nfex) { - throw (SQLException)createException( - DOUBLE_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(DOUBLE_CONVERSION_ERROR + " " + value); } } @@ -211,8 +205,7 @@ // check if value is within bounds if (value.compareTo(BD_MAX_DOUBLE) > 0 || value.compareTo(BD_MIN_DOUBLE) < 0) - throw (SQLException)createException( - DOUBLE_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(DOUBLE_CONVERSION_ERROR + " " + value); setDouble(value.doubleValue()); } Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -16,36 +16,36 @@ * * All rights reserved. */ - package org.firebirdsql.jdbc.field; -import org.firebirdsql.gds.DatabaseParameterBuffer; -import org.firebirdsql.gds.XSQLVAR; -import org.firebirdsql.gds.ISCConstants; -import org.firebirdsql.gds.impl.DatabaseParameterBufferExtension; -import org.firebirdsql.gds.impl.GDSHelper; -import org.firebirdsql.jdbc.*; - +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; import java.sql.Array; +import java.sql.Blob; import java.sql.Clob; +import java.sql.Date; import java.sql.Ref; import java.sql.SQLException; -import java.sql.Types; -import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; -import java.sql.Blob; - -import java.math.BigDecimal; +import java.sql.Types; import java.util.Calendar; import java.util.Map; -import java.io.InputStream; -import java.io.Reader; +import org.firebirdsql.gds.DatabaseParameterBuffer; +import org.firebirdsql.gds.ISCConstants; +import org.firebirdsql.gds.XSQLVAR; +import org.firebirdsql.gds.impl.DatabaseParameterBufferExtension; +import org.firebirdsql.gds.impl.GDSHelper; +import org.firebirdsql.jdbc.FBBlob; +import org.firebirdsql.jdbc.FBClob; +import org.firebirdsql.jdbc.FBDriverNotCapableException; +import org.firebirdsql.jdbc.FBSQLException; /** * Describe class <code>FBField</code> here. - * + * * @author <a href="mailto:rro...@us...">Roman Rokytskyy</a> * @version 1.0 */ @@ -54,35 +54,25 @@ static final String SHORT_CONVERSION_ERROR = "Error converting to short."; static final String INT_CONVERSION_ERROR = "Error converting to int."; static final String LONG_CONVERSION_ERROR = "Error converting to long."; - static final String FLOAT_CONVERSION_ERROR = "Error converting to float."; static final String DOUBLE_CONVERSION_ERROR = "Error converting to double."; static final String BIGDECIMAL_CONVERSION_ERROR = "Error converting to big decimal."; - static final String BOOLEAN_CONVERSION_ERROR = "Error converting to boolean."; - static final String STRING_CONVERSION_ERROR = "Error converting to string."; - static final String OBJECT_CONVERSION_ERROR = "Error converting to object."; - static final String DATE_CONVERSION_ERROR = "Error converting to date."; static final String TIME_CONVERSION_ERROR = "Error converting to time."; static final String TIMESTAMP_CONVERSION_ERROR = "Error converting to timestamp."; - static final String ASCII_STREAM_CONVERSION_ERROR = "Error converting to ascii stream."; static final String UNICODE_STREAM_CONVERSION_ERROR = "Error converting to unicode stream."; static final String BINARY_STREAM_CONVERSION_ERROR = "Error converting to binary stream."; static final String CHARACTER_STREAM_CONVERSION_ERROR = "Error converting to character stream."; - static final String BYTES_CONVERSION_ERROR = "Error converting to array of bytes."; - - static final String BLOB_CONVERSION_ERROR = "Error converting to Firebird BLOB object"; - + static final String BLOB_CONVERSION_ERROR = "Error converting to Firebird BLOB object"; static final String CLOB_CONVERSION_ERROR = "Error converting to Firebird CLOB object"; - - static final String SQL_TYPE_NOT_SUPPORTED = "SQL type for this field is not yet supported."; - static final String SQL_ARRAY_NOT_SUPPORTED = "Types.ARRAY: " + SQL_TYPE_NOT_SUPPORTED; + static final String SQL_TYPE_NOT_SUPPORTED = "SQL type for this field is not yet supported."; + static final String SQL_ARRAY_NOT_SUPPORTED = "Types.ARRAY: " + FBField.SQL_TYPE_NOT_SUPPORTED; static final byte BYTE_NULL_VALUE = 0; static final short SHORT_NULL_VALUE = 0; @@ -91,7 +81,6 @@ static final float FLOAT_NULL_VALUE = 0.0f; static final double DOUBLE_NULL_VALUE = 0.0; static final BigDecimal BIGDECIMAL_NULL_VALUE = null; - static final String STRING_NULL_VALUE = null; static final Object OBJECT_NULL_VALUE = null; @@ -106,42 +95,41 @@ static final byte[] BYTES_NULL_VALUE = null; static final FBBlob BLOB_NULL_VALUE = null; static final FBClob CLOB_NULL_VALUE = null; - + static final byte MAX_BYTE_VALUE = Byte.MAX_VALUE; static final byte MIN_BYTE_VALUE = Byte.MIN_VALUE; - + static final short MAX_SHORT_VALUE = Short.MAX_VALUE; static final short MIN_SHORT_VALUE = Short.MIN_VALUE; - + static final int MAX_INT_VALUE = Integer.MAX_VALUE; static final int MIN_INT_VALUE = Integer.MIN_VALUE; - + static final long MAX_LONG_VALUE = Long.MAX_VALUE; static final long MIN_LONG_VALUE = Long.MIN_VALUE; - + static final float MAX_FLOAT_VALUE = Float.MAX_VALUE; - static final float MIN_FLOAT_VALUE = -1 * MAX_FLOAT_VALUE; - + static final float MIN_FLOAT_VALUE = -1 * FBField.MAX_FLOAT_VALUE; + static final double MAX_DOUBLE_VALUE = Double.MAX_VALUE; - static final double MIN_DOUBLE_VALUE = -1 * MAX_DOUBLE_VALUE; - + static final double MIN_DOUBLE_VALUE = -1 * FBField.MAX_DOUBLE_VALUE; + protected XSQLVAR field; - private FieldDataProvider dataProvider; + private final FieldDataProvider dataProvider; protected int numCol; protected GDSHelper gdsHelper = null; protected String iscEncoding = null; - protected String javaEncoding = null; + protected String javaEncoding = null; protected String mappingPath = null; protected int requiredType; protected int scale = -1; - FBField(XSQLVAR field, FieldDataProvider dataProvider, int requiredType) - throws SQLException - { - if (field == null) throw new FBSQLException( - "Cannot create FBField instance for null as XSQLVAR.", - FBSQLException.SQL_STATE_INVALID_ARG_VALUE); - + FBField(XSQLVAR field, FieldDataProvider dataProvider, int requiredType) throws SQLException { + if (field == null) { + throw new FBSQLException("Cannot create FBField instance for null as XSQLVAR.", + FBSQLException.SQL_STATE_INVALID_ARG_VALUE); + } + this.field = field; this.dataProvider = dataProvider; this.requiredType = requiredType; @@ -150,23 +138,16 @@ protected byte[] getFieldData() { return dataProvider.getFieldData(); } - + protected void setFieldData(byte[] data) { dataProvider.setFieldData(data); } - + /** - * Constructs an exception with appropriate message. - * @todo add XSQLVAR type into the message + * @return <code>true</code> if the corresponding <code>field</code> is + * <code>null</code>, otherwise <code>false</code>. + * @throws SQLException */ - static Throwable createException(String message) { - return new TypeConversionException(message); - } - - /** - * @return <code>true</code> if the corresponding <code>field</code> - * is <code>null</code>, otherwise <code>false</code>. - */ public boolean isNull() throws SQLException { return dataProvider.getFieldData() == null; } @@ -177,91 +158,95 @@ public void setConnection(GDSHelper gdsHelper) { this.gdsHelper = gdsHelper; - if (gdsHelper != null) + if (gdsHelper != null) { iscEncoding = gdsHelper.getIscEncoding(); - - if (iscEncoding != null && (iscEncoding.equalsIgnoreCase("NONE") - || iscEncoding.equalsIgnoreCase("BINARY"))) + } + + if (iscEncoding != null + && (iscEncoding.equalsIgnoreCase("NONE") || iscEncoding.equalsIgnoreCase("BINARY"))) { iscEncoding = null; - + } + if (gdsHelper != null) { javaEncoding = gdsHelper.getJavaEncoding(); mappingPath = gdsHelper.getMappingPath(); } } - + /** * Set the required type for {@link #getObject()} conversion. * - * @param requiredType required type, one of the {@link java.sql.Types} - * constants. + * @param requiredType + * required type, one of the {@link java.sql.Types} constants. */ public void setRequiredType(int requiredType) { - this.requiredType =requiredType; + this.requiredType = requiredType; } - + /** * @return <code>true</code> if the field is of type <code>type</code>. * TODO write correct ISCConstants.SQL_QUAD support */ public final static boolean isType(XSQLVAR field, int type) { // turn off null flag, in this case we're not interested in it. - int tempType = field.sqltype & ~1; - switch(tempType) { - case ISCConstants.SQL_ARRAY : - return (type == Types.ARRAY); + final int tempType = field.sqltype & ~1; + switch (tempType) { + case ISCConstants.SQL_ARRAY: + return type == Types.ARRAY; - case ISCConstants.SQL_BLOB : - if (field.sqlsubtype < 0) - return (type == Types.BLOB); - if (field.sqlsubtype == 1) - return (type == Types.LONGVARCHAR); - else - return (type == Types.LONGVARBINARY) || - (type == Types.VARBINARY) || - (type == Types.BINARY); + case ISCConstants.SQL_BLOB: + if (field.sqlsubtype < 0) { + return type == Types.BLOB; + } + if (field.sqlsubtype == 1) { + return type == Types.LONGVARCHAR; + } else { + return type == Types.LONGVARBINARY + || type == Types.VARBINARY + || type == Types.BINARY; + } - case ISCConstants.SQL_D_FLOAT : - return false; // not supported right now + case ISCConstants.SQL_D_FLOAT: + return false; // not supported right now - case ISCConstants.SQL_DOUBLE : - return (type == Types.DOUBLE); + case ISCConstants.SQL_DOUBLE: + return type == Types.DOUBLE; - case ISCConstants.SQL_FLOAT : - return (type == Types.FLOAT); + case ISCConstants.SQL_FLOAT: + return type == Types.FLOAT; - case ISCConstants.SQL_INT64 : - return (type == Types.BIGINT); + case ISCConstants.SQL_INT64: + return type == Types.BIGINT; - case ISCConstants.SQL_LONG : - return (type == Types.INTEGER); + case ISCConstants.SQL_LONG: + return type == Types.INTEGER; - case ISCConstants.SQL_QUAD: - return false; //not supported right now + case ISCConstants.SQL_QUAD: + return false; // not supported right now - case ISCConstants.SQL_SHORT: - return (type == Types.SMALLINT); + case ISCConstants.SQL_SHORT: + return type == Types.SMALLINT; - case ISCConstants.SQL_TEXT: - return (type == Types.CHAR); + case ISCConstants.SQL_TEXT: + return type == Types.CHAR; - case ISCConstants.SQL_TIMESTAMP: - return (type == Types.TIMESTAMP); + case ISCConstants.SQL_TIMESTAMP: + return type == Types.TIMESTAMP; - case ISCConstants.SQL_TYPE_DATE: - return (type == Types.DATE); + case ISCConstants.SQL_TYPE_DATE: + return type == Types.DATE; - case ISCConstants.SQL_TYPE_TIME: - return (type == Types.TIME); + case ISCConstants.SQL_TYPE_TIME: + return type == Types.TIME; - case ISCConstants.SQL_VARYING: - return (type == Types.VARCHAR); - - case ISCConstants.SQL_NULL: - return false; + case ISCConstants.SQL_VARYING: + return type == Types.VARCHAR; - default: - return false; + case ISCConstants.SQL_NULL: + return false; + + default: + return false; } } @@ -271,439 +256,443 @@ */ public final static boolean isCompatible(XSQLVAR field, int type) { // turn off null flag, in this case we're not interested in it. - int tempType = field.sqltype & ~1; - switch(tempType) { - // this type does not belong to JDBC v.1.20, but as long as - // Firebird supports arrays, lets use them. - case ISCConstants.SQL_ARRAY : - return (type == Types.ARRAY); + final int tempType = field.sqltype & ~1; + switch (tempType) { + // this type does not belong to JDBC v.1.20, but as long as + // Firebird supports arrays, lets use them. + case ISCConstants.SQL_ARRAY: + return type == Types.ARRAY; // this type does not belong to JDBC v.1.20, but as long as // Firebird supports arrays, lets use them. - case ISCConstants.SQL_BLOB : - return (type == Types.BLOB) || - (type == Types.BINARY) || - (type == Types.VARBINARY) || - (type == Types.LONGVARBINARY) || - (type == Types.LONGVARCHAR) - ; + case ISCConstants.SQL_BLOB: + return (type == Types.BLOB) || + (type == Types.BINARY) || + (type == Types.VARBINARY) || + (type == Types.LONGVARBINARY) || + (type == Types.LONGVARCHAR) + ; // Unfortunately we do not know the SQL correspondence to these type - case ISCConstants.SQL_QUAD: - case ISCConstants.SQL_D_FLOAT : - return false; + case ISCConstants.SQL_QUAD: + case ISCConstants.SQL_D_FLOAT: + return false; // currently we do not provide compatibility with CHAR and VARCHAR - case ISCConstants.SQL_DOUBLE : - case ISCConstants.SQL_FLOAT : - case ISCConstants.SQL_INT64 : - case ISCConstants.SQL_LONG : - case ISCConstants.SQL_SHORT: - return (type == Types.DOUBLE) || - (type == Types.FLOAT) || - (type == Types.REAL) || - (type == Types.BIGINT) || - (type == Types.INTEGER) || - (type == Types.SMALLINT) || - (type == Types.TINYINT) || - (type == Types.NUMERIC) || - (type == Types.DECIMAL) || - (type == Types.BIT) - ; + case ISCConstants.SQL_DOUBLE: + case ISCConstants.SQL_FLOAT: + case ISCConstants.SQL_INT64: + case ISCConstants.SQL_LONG: + case ISCConstants.SQL_SHORT: + return (type == Types.DOUBLE) || + (type == Types.FLOAT) || + (type == Types.REAL) || + (type == Types.BIGINT) || + (type == Types.INTEGER) || + (type == Types.SMALLINT) || + (type == Types.TINYINT) || + (type == Types.NUMERIC) || + (type == Types.DECIMAL) || + (type == Types.BIT) + ; - case ISCConstants.SQL_TEXT: - case ISCConstants.SQL_VARYING: - return (type == Types.CHAR) || - (type == Types.VARCHAR) || - (type == Types.LONGVARCHAR) - ; + case ISCConstants.SQL_TEXT: + case ISCConstants.SQL_VARYING: + return (type == Types.CHAR) || + (type == Types.VARCHAR) || + (type == Types.LONGVARCHAR) + ; - case ISCConstants.SQL_TIMESTAMP: - return (type == Types.TIMESTAMP) || - (type == Types.TIME) || - (type == Types.DATE); + case ISCConstants.SQL_TIMESTAMP: + return (type == Types.TIMESTAMP) || + (type == Types.TIME) || + (type == Types.DATE); - case ISCConstants.SQL_TYPE_DATE: - return (type == Types.DATE) || - (type == Types.TIMESTAMP); + case ISCConstants.SQL_TYPE_DATE: + return (type == Types.DATE) || + (type == Types.TIMESTAMP); - case ISCConstants.SQL_TYPE_TIME: - return (type == Types.TIME) || - (type == Types.TIMESTAMP); - - case ISCConstants.SQL_NULL: - return true; + case ISCConstants.SQL_TYPE_TIME: + return (type == Types.TIME) || + (type == Types.TIMESTAMP); - default: - return false; + case ISCConstants.SQL_NULL: + return true; + + default: + return false; } } - + public final static boolean isNullType(XSQLVAR field) { - int tempType = field.sqltype & ~1; + final int tempType = field.sqltype & ~1; return tempType == ISCConstants.SQL_NULL; } - + /** * This is a factory method that creates appropriate instance of the * <code>FBField</code> class according to the SQL datatype. This instance * knows how to perform all necessary type conversions. */ - public final static FBField createField(XSQLVAR field, FieldDataProvider dataProvider, GDSHelper gdsHelper, boolean cached) - throws SQLException { - FBField result = createField(field, dataProvider, cached); + public final static FBField createField(XSQLVAR field, FieldDataProvider dataProvider, + GDSHelper gdsHelper, boolean cached) throws SQLException { + final FBField result = FBField.createField(field, dataProvider, cached); result.setConnection(gdsHelper); return result; } - + private static FBField createField(XSQLVAR field, FieldDataProvider dataProvider, boolean cached) - throws SQLException { - - if (isType(field, Types.SMALLINT)) - if (field.sqlscale == 0) + throws SQLException { + + if (FBField.isType(field, Types.SMALLINT)) { + if (field.sqlscale == 0) { return new FBShortField(field, dataProvider, Types.SMALLINT); - else - return new FBBigDecimalField(field, dataProvider, field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); - else - if (isType(field, Types.INTEGER)) - if (field.sqlscale == 0) + } else { + return new FBBigDecimalField(field, dataProvider, + field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); + } + } else if (FBField.isType(field, Types.INTEGER)) { + if (field.sqlscale == 0) { return new FBIntegerField(field, dataProvider, Types.INTEGER); - else - return new FBBigDecimalField(field, dataProvider, field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); - else - if (isType(field, Types.BIGINT)) - if (field.sqlscale == 0) + } else { + return new FBBigDecimalField(field, dataProvider, + field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); + } + } else if (FBField.isType(field, Types.BIGINT)) { + if (field.sqlscale == 0) { return new FBLongField(field, dataProvider, Types.BIGINT); - else - return new FBBigDecimalField(field, dataProvider, field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); - else - if (isType(field, Types.FLOAT)) + } else { + return new FBBigDecimalField(field, dataProvider, + field.sqlsubtype == 2 ? Types.DECIMAL : Types.NUMERIC); + } + } else if (FBField.isType(field, Types.FLOAT)) { return new FBFloatField(field, dataProvider, Types.FLOAT); - else - if (isType(field, Types.DOUBLE)) + } else if (FBField.isType(field, Types.DOUBLE)) { return new FBDoubleField(field, dataProvider, Types.DOUBLE); - else - if (isType(field, Types.CHAR)) + } else if (FBField.isType(field, Types.CHAR)) { /* - - // Commented by R.Rokytskyy. Until the bug is fixed in the server - // we use "workaround" implementation of the string field. Should - // be replaced with original one as soon as bug is fixed in the - // engine. - - return new FBStringField(field, dataProvider, Types.CHAR); - */ + * TODO: Remove workaround + * Commented by R.Rokytskyy. Until the bug is fixed in the server + * we use "workaround" implementation of the string field. Should + * be replaced with original one as soon as bug is fixed in the + * engine. + * + * return new FBStringField(field, dataProvider, Types.CHAR); + */ return new FBWorkaroundStringField(field, dataProvider, Types.CHAR); - else - if (isType(field, Types.VARCHAR)) + } else if (FBField.isType(field, Types.VARCHAR)) { /* - - // Commented by R.Rokytskyy. Until the bug is fixed in the server - // we use "workaround" implementation of the string field. Should - // be replaced with original one as soon as bug is fixed in the - // engine. - - return new FBStringField(field, dataProvider, Types.VARCHAR); - */ + * TODO: Remove workaround + * Commented by R.Rokytskyy. Until the bug is fixed in the server + * we use "workaround" implementation of the string field. Should + * be replaced with original one as soon as bug is fixed in the + * engine. + * + * return new FBStringField(field, dataProvider, Types.VARCHAR); + */ return new FBWorkaroundStringField(field, dataProvider, Types.VARCHAR); - else - if (isType(field, Types.DATE)) + } else if (FBField.isType(field, Types.DATE)) { return new FBDateField(field, dataProvider, Types.DATE); - else - if (isType(field, Types.TIME)) + } else if (FBField.isType(field, Types.TIME)) { return new FBTimeField(field, dataProvider, Types.TIME); - else - if (isType(field, Types.TIMESTAMP)) + } else if (FBField.isType(field, Types.TIMESTAMP)) { return new FBTimestampField(field, dataProvider, Types.TIMESTAMP); - else - if (isType(field, Types.BLOB)) { - if (cached) - return new FBCachedBlobField(field, dataProvider, Types.BLOB); - else - return new FBBlobField(field, dataProvider, Types.BLOB); - } else - if (isType(field, Types.LONGVARBINARY)) { - if (cached) + } else if (FBField.isType(field, Types.BLOB)) { + if (cached) { + return new FBCachedBlobField(field, dataProvider, Types.BLOB); + } else { + return new FBBlobField(field, dataProvider, Types.BLOB); + } + } else if (FBField.isType(field, Types.LONGVARBINARY)) { + if (cached) { return new FBCachedBlobField(field, dataProvider, Types.LONGVARBINARY); - else + } else { return new FBBlobField(field, dataProvider, Types.LONGVARBINARY); - } else - if (isType(field, Types.LONGVARCHAR)) - if (cached) + } + } else if (FBField.isType(field, Types.LONGVARCHAR)) { + if (cached) { return new FBCachedLongVarCharField(field, dataProvider, Types.LONGVARCHAR); - else + } else { return new FBLongVarCharField(field, dataProvider, Types.LONGVARCHAR); - else - if (isType(field, Types.ARRAY)) - throw (SQLException)createException(SQL_ARRAY_NOT_SUPPORTED); - else - if (isNullType(field)) - // TODO Shouldn't this be Types.NULL ? - return new FBNullField(field, dataProvider, Types.VARCHAR); - else - throw (SQLException)createException(SQL_TYPE_NOT_SUPPORTED); + } + } else if (FBField.isType(field, Types.ARRAY)) { + throw new FBDriverNotCapableException(FBField.SQL_ARRAY_NOT_SUPPORTED); + } else if (FBField.isNullType(field)) { + return new FBNullField(field, dataProvider, Types.NULL); + } else { + throw new FBDriverNotCapableException(FBField.SQL_TYPE_NOT_SUPPORTED); + } } - + /** * Returns the name of the column as declared in the XSQLVAR. */ - public String getName() { return field.sqlname; } + public String getName() { + return field.sqlname; + } /** * Returns the alias of the column as declared in XSQLVAR. */ - public String getAlias() { return field.aliasname; } + public String getAlias() { + return field.aliasname; + } /** * Returns the relation to which belongs column as declared in XSQLVAR. */ - public String getRelationName() { return field.relname; } - + public String getRelationName() { + return field.relname; + } + /** * Close this field. This method tells field implementation to release all * resources allocated when field methods were called. * - * @throws SQLException if field cannot be closed. + * @throws SQLException + * if field cannot be closed. */ public void close() throws SQLException { // default behaviour is to do nothing. } /* - * All these methods simply throw an exception - * when invoked. All subclasses should implement - * relevant mathods with conversions. + * All these methods simply throw an exception when invoked. All subclasses + * should implement relevant methods with conversions. */ - //--- getters + // --- getters public byte getByte() throws SQLException { - throw (SQLException)createException( - BYTE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BYTE_CONVERSION_ERROR); } + public short getShort() throws SQLException { - throw (SQLException)createException( - SHORT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.SHORT_CONVERSION_ERROR); } + public int getInt() throws SQLException { - throw (SQLException)createException( - INT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.INT_CONVERSION_ERROR); } + public long getLong() throws SQLException { - throw (SQLException)createException( - LONG_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.LONG_CONVERSION_ERROR); } + public float getFloat() throws SQLException { - throw (SQLException)createException( - FLOAT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.FLOAT_CONVERSION_ERROR); } + public double getDouble() throws SQLException { - throw (SQLException)createException( - DOUBLE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.DOUBLE_CONVERSION_ERROR); } + public BigDecimal getBigDecimal() throws SQLException { - throw (SQLException)createException( - BIGDECIMAL_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BIGDECIMAL_CONVERSION_ERROR); } + public BigDecimal getBigDecimal(int scale) throws SQLException { return getBigDecimal(); } + public boolean getBoolean() throws SQLException { - throw (SQLException)createException( - BOOLEAN_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BOOLEAN_CONVERSION_ERROR); } + public String getString() throws SQLException { - throw (SQLException)createException( - STRING_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.STRING_CONVERSION_ERROR); } - + private boolean isOctetsAsBytes() { - - if (gdsHelper == null) + if (gdsHelper == null) { return false; - + } + return gdsHelper.getDatabaseParameterBuffer().hasArgument( - DatabaseParameterBufferExtension.OCTETS_AS_BYTES); + DatabaseParameterBufferExtension.OCTETS_AS_BYTES); } - + public Object getObject() throws SQLException { - - if (isNull()) + + if (isNull()) { return null; - + } + switch (requiredType) { - case Types.CHAR : - case Types.VARCHAR : - case Types.LONGVARCHAR : - // check whether OCTETS should be returned as byte[] - if (isOctetsAsBytes() && field.sqlsubtype == 1) - return getBytes(); - else - return getString(); - - case Types.NUMERIC : - case Types.DECIMAL : - if (scale == -1) - return getBigDecimal(); - else - return getBigDecimal(scale); - - case Types.BIT : - case Types.BOOLEAN : - return Boolean.valueOf(getBoolean()); - - case Types.TINYINT : - case Types.SMALLINT : - case Types.INTEGER : - return Integer.valueOf(getInt()); - - case Types.BIGINT : - return Long.valueOf(getLong()); - - case Types.REAL : - return Float.valueOf(getFloat()); - - case Types.FLOAT : - case Types.DOUBLE : - return Double.valueOf(getDouble()); - - case Types.BINARY : - case Types.VARBINARY : - case Types.LONGVARBINARY : + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: + // check whether OCTETS should be returned as byte[] + if (isOctetsAsBytes() && field.sqlsubtype == 1) { return getBytes(); - - case Types.DATE : - return getDate(); - - case Types.TIME : - return getTime(); - - case Types.TIMESTAMP : - return getTimestamp(); - - case Types.CLOB : - return getClob(); - - case Types.BLOB : - return getBlob(); - - case Types.ARRAY : - return getArray(); - - default : - throw (SQLException)createException( - OBJECT_CONVERSION_ERROR); + } else { + return getString(); + } + + case Types.NUMERIC: + case Types.DECIMAL: + if (scale == -1) { + return getBigDecimal(); + } else { + return getBigDecimal(scale); + } + + case Types.BIT: + case Types.BOOLEAN: + return Boolean.valueOf(getBoolean()); + + case Types.TINYINT: + case Types.SMALLINT: + case Types.INTEGER: + return Integer.valueOf(getInt()); + + case Types.BIGINT: + return Long.valueOf(getLong()); + + case Types.REAL: + return Float.valueOf(getFloat()); + + case Types.FLOAT: + case Types.DOUBLE: + return Double.valueOf(getDouble()); + + case Types.BINARY: + case Types.VARBINARY: + case Types.LONGVARBINARY: + return getBytes(); + + case Types.DATE: + return getDate(); + + case Types.TIME: + return getTime(); + + case Types.TIMESTAMP: + return getTimestamp(); + + case Types.CLOB: + return getClob(); + + case Types.BLOB: + return getBlob(); + + case Types.ARRAY: + return getArray(); + + default: + throw new TypeConversionException(FBField.OBJECT_CONVERSION_ERROR); } - } - public Object getObject(Map<String, Class<?>> map) throws SQLException { - throw new FBDriverNotCapableException(); + + public Object getObject(Map<String, Class<?>> map) throws SQLException { + throw new FBDriverNotCapableException(); } + public InputStream getAsciiStream() throws SQLException { - throw (SQLException)createException( - ASCII_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.ASCII_STREAM_CONVERSION_ERROR); } + public InputStream getUnicodeStream() throws SQLException { - throw (SQLException)createException( - UNICODE_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.UNICODE_STREAM_CONVERSION_ERROR); } + public InputStream getBinaryStream() throws SQLException { - throw (SQLException)createException( - BINARY_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BINARY_STREAM_CONVERSION_ERROR); } - public Reader getCharacterStream() throws SQLException { - InputStream is = getBinaryStream(); - if (is==null) - return READER_NULL_VALUE; - else + + public Reader getCharacterStream() throws SQLException { + final InputStream is = getBinaryStream(); + if (is == null) { + return FBField.READER_NULL_VALUE; + } else { return TranslatingReader.getInstance(is, javaEncoding, mappingPath); - } + } + } + public byte[] getBytes() throws SQLException { - throw (SQLException)createException( - BYTES_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BYTES_CONVERSION_ERROR); } + public Blob getBlob() throws SQLException { - throw (SQLException)createException( - BLOB_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BLOB_CONVERSION_ERROR); } + public Date getDate() throws SQLException { - throw (SQLException)createException( - DATE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.DATE_CONVERSION_ERROR); } + public Date getDate(Calendar cal) throws SQLException { - throw (SQLException)createException( - DATE_CONVERSION_ERROR).fillInStackTrace(); - } + throw new TypeConversionException(FBField.DATE_CONVERSION_ERROR); + } + public Time getTime() throws SQLException { - throw (SQLException)createException( - TIME_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIME_CONVERSION_ERROR); } + public Time getTime(Calendar cal) throws SQLException { - throw (SQLException)createException( - TIME_CONVERSION_ERROR).fillInStackTrace(); - } + throw new TypeConversionException(FBField.TIME_CONVERSION_ERROR); + } + public Timestamp getTimestamp() throws SQLException { - throw (SQLException)createException( - TIMESTAMP_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIMESTAMP_CONVERSION_ERROR); } + public Timestamp getTimestamp(Calendar cal) throws SQLException { - throw (SQLException)createException( - TIMESTAMP_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIMESTAMP_CONVERSION_ERROR); } - public Ref getRef() throws SQLException { - throw new FBDriverNotCapableException(); + + public Ref getRef() throws SQLException { + throw new FBDriverNotCapableException(); } - public Clob getClob() throws SQLException { - throw (SQLException)createException( - BLOB_CONVERSION_ERROR).fillInStackTrace(); + + public Clob getClob() throws SQLException { + throw new TypeConversionException(FBField.BLOB_CONVERSION_ERROR); } - public Array getArray() throws SQLException { - throw new FBDriverNotCapableException(); + + public Array getArray() throws SQLException { + throw new FBDriverNotCapableException(); } - //--- setters + // --- setters + public void setByte(byte value) throws SQLException { - throw (SQLException)createException( - BYTE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BYTE_CONVERSION_ERROR); } + public void setShort(short value) throws SQLException { - throw (SQLException)createException( - SHORT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.SHORT_CONVERSION_ERROR); } + public void setInteger(int value) throws SQLException { - throw (SQLException)createException( - INT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.INT_CONVERSION_ERROR); } + public void setLong(long value) throws SQLException { - throw (SQLException)createException( - LONG_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.LONG_CONVERSION_ERROR); } + public void setFloat(float value) throws SQLException { - throw (SQLException)createException( - FLOAT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.FLOAT_CONVERSION_ERROR); } + public void setDouble(double value) throws SQLException { - throw (SQLException)createException( - DOUBLE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.DOUBLE_CONVERSION_ERROR); } + public void setBigDecimal(BigDecimal value) throws SQLException { - throw (SQLException)createException( - BIGDECIMAL_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BIGDECIMAL_CONVERSION_ERROR); } + public void setBoolean(boolean value) throws SQLException { - throw (SQLException)createException( - BOOLEAN_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BOOLEAN_CONVERSION_ERROR); } + public void setString(String value) throws SQLException { - throw (SQLException)createException( - STRING_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.STRING_CONVERSION_ERROR); } + public void setObject(Object value) throws SQLException { - /* - throw (SQLException)createException( - OBJECT_CONVERSION_ERROR).fillInStackTrace(); - */ if (value == null) { setNull(); return; @@ -711,120 +700,104 @@ if (value instanceof BigDecimal) { setBigDecimal((BigDecimal) value); - } else - if (value instanceof Blob) { - if (value instanceof FBBlob) - setBlob((FBBlob)value); - else - setBinaryStream(((Blob) value).getBinaryStream(), - (int)((Blob)value).length()); - } else - if (value instanceof Boolean) { + } else if (value instanceof Blob) { + if (value instanceof FBBlob) { + setBlob((FBBlob) value); + } else { + setBinaryStream(((Blob) value).getBinaryStream(), (int) ((Blob) value).length()); + } + } else if (value instanceof Boolean) { setBoolean(((Boolean) value).booleanValue()); - } else - if (value instanceof Byte) { + } else if (value instanceof Byte) { setByte(((Byte) value).byteValue()); - } else - if (value instanceof byte[]) { + } else if (value instanceof byte[]) { setBytes((byte[]) value); - } else - if (value instanceof Date) { + } else if (value instanceof Date) { setDate((Date) value); - } else - if (value instanceof Double) { + } else if (value instanceof Double) { setDouble(((Double) value).doubleValue()); - } else - if (value instanceof Float) { + } else if (value instanceof Float) { setFloat(((Float) value).floatValue()); - } else - if (value instanceof Integer) { + } else if (value instanceof Integer) { setInteger(((Integer) value).intValue()); - } else - if (value instanceof Long) { + } else if (value instanceof Long) { setLong(((Long) value).longValue()); - } else - if (value instanceof Short) { + } else if (value instanceof Short) { setShort(((Short) value).shortValue()); - } else - if (value instanceof String) { + } else if (value instanceof String) { setString((String) value); - } else - if (value instanceof Time) { + } else if (value instanceof Time) { setTime((Time) value); - } else - if (value instanceof Timestamp) { + } else if (value instanceof Timestamp) { setTimestamp((Timestamp) value); } else { - throw (SQLException) createException( - OBJECT_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.OBJECT_CONVERSION_ERROR); } } + public void setAsciiStream(InputStream in, int length) throws SQLException { - throw (SQLException)createException( - ASCII_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.ASCII_STREAM_CONVERSION_ERROR); } + public void setUnicodeStream(InputStream in, int length) throws SQLException { - throw (SQLException)createException( - UNICODE_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.UNICODE_STREAM_CONVERSION_ERROR); } + public void setBinaryStream(InputStream in, int length) throws SQLException { - throw (SQLException)createException( - BINARY_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BINARY_STREAM_CONVERSION_ERROR); } + public void setCharacterStream(Reader in, int length) throws SQLException { - throw (SQLException)createException( - ASCII_STREAM_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.ASCII_STREAM_CONVERSION_ERROR); } + public void setBytes(byte[] value) throws SQLException { - throw (SQLException)createException( - BYTES_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BYTES_CONVERSION_ERROR); } + public void setDate(Date value, Calendar cal) throws SQLException { - throw (SQLException)createException( - DATE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.DATE_CONVERSION_ERROR); } + public void setDate(Date value) throws SQLException { - throw (SQLException)createException( - DATE_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.DATE_CONVERSION_ERROR); } + public void setTime(Time value, Calendar cal) throws SQLException { - throw (SQLException)createException( - TIME_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIME_CONVERSION_ERROR); } + public void setTime(Time value) throws SQLException { - throw (SQLException)createException( - TIME_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIME_CONVERSION_ERROR); } + public void setTimestamp(Timestamp value, Calendar cal) throws SQLException { - throw (SQLException)createException( - TIMESTAMP_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIMESTAMP_CONVERSION_ERROR); } + public void setTimestamp(Timestamp value) throws SQLException { - throw (SQLException)createException( - TIMESTAMP_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.TIMESTAMP_CONVERSION_ERROR); } + public void setBlob(FBBlob blob) throws SQLException { - throw (SQLException)createException( - BLOB_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.BLOB_CONVERSION_ERROR); } - + public void setClob(FBClob clob) throws SQLException { - throw (SQLException)createException( - CLOB_CONVERSION_ERROR).fillInStackTrace(); + throw new TypeConversionException(FBField.CLOB_CONVERSION_ERROR); } - + // This method is only for the tests // - void copyOI(){ + void copyOI() { dataProvider.setFieldData(dataProvider.getFieldData()); } protected boolean isInvertTimeZone() { if (gdsHelper == null) return false; - - DatabaseParameterBuffer dpb = gdsHelper.getDatabaseParameterBuffer(); + + final DatabaseParameterBuffer dpb = gdsHelper.getDatabaseParameterBuffer(); return dpb.hasArgument(DatabaseParameterBufferExtension.TIMESTAMP_USES_LOCAL_TIMEZONE); } - } Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBFloatField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBFloatField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBFloatField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -53,8 +53,7 @@ // check if value is within bounds if (value > MAX_BYTE_VALUE || value < MIN_BYTE_VALUE) - throw (SQLException)createException( - BYTE_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(BYTE_CONVERSION_ERROR + " " + value); return (byte) value; } @@ -67,8 +66,7 @@ // check if value is within bounds if (value > MAX_SHORT_VALUE || value < MIN_SHORT_VALUE) - throw (SQLException)createException( - SHORT_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(SHORT_CONVERSION_ERROR + " " + value); return (short) value; } @@ -81,8 +79,7 @@ // check if value is within bounds if (value > MAX_INT_VALUE || value < MIN_INT_VALUE) - throw (SQLException)createException( - INT_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(INT_CONVERSION_ERROR + " " + value); return (int) value; } @@ -95,8 +92,7 @@ // check if value is within bounds if (value > MAX_LONG_VALUE || value < MIN_LONG_VALUE) - throw (SQLException)createException( - LONG_CONVERSION_ERROR + " " + value).fillInStackTrace(); + throw new TypeConversionException(LONG_CONVERSION_ERROR + " " + value); return (long) value; } @@ -150,8 +146,7 @@ try { setFloat(Float.parseFloat(value)); } catch(NumberFormatException nfex) { - throw (SQLException)createException( - FLOAT_CONVERSION_ERROR+" "+value).fillInStackTrace(); + throw new TypeConversionException(FLOAT_CONVERSION_ERROR + " " + value); } } @@ -172,8 +167,7 @@ // TODO: Shouldn't we just overflow to +/-INF? if (value > MAX_FLOAT_VALUE || value < MIN_FLOAT_VALUE) - throw (SQLException)createException( - FLOAT_CONVERSION_ERROR+" "+value).fillInStackTrace(); + throw new TypeConversionException(FLOAT_CONVERSION_ERROR + " " + value); setFloat((float)value); } @@ -199,8 +193,7 @@ // check if value is within bounds if (value.compareTo(BD_MAX_FLOAT) > 0 || value.compareTo(BD_MIN_FLOAT) < 0) - throw (SQLException)createException( - BIGDECIMAL_CONVERSION_ERROR+" "+value).fillInStackTrace(); + throw new TypeConversionException(BIGDECIMAL_CONVERSION_ERROR + " " + value); setFloat(value.floatValue()); } Modified: client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBIntegerField.java =================================================================== --- client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBIntegerField.java 2012-10-20 16:54:33 UTC (rev 57253) +++ client-java/trunk/src/main/org/firebirdsql/jdbc/field/FBIntegerField.java 2012-10-21 08:13:07 UTC (rev 57254) @@ -50,8 +50,7 @@ // check if value is within bounds if (value > MAX_BYTE_VALUE || ... [truncated message content] |