Search in sources :

Example 6 with FBFlushableField

use of org.firebirdsql.jdbc.field.FBFlushableField in project jaybird by FirebirdSQL.

the class AbstractPreparedStatement method flushFields.

/**
 * Flush fields that might have cached data.
 *
 * @throws SQLException if something went wrong.
 */
private void flushFields() throws SQLException {
    // flush any cached data that can be hanging
    for (int i = 0; i < isParamSet.length; i++) {
        FBField field = getField(i + 1);
        if (!(field instanceof FBFlushableField))
            continue;
        ((FBFlushableField) field).flushCachedData();
    }
}
Also used : FBField(org.firebirdsql.jdbc.field.FBField) FBFlushableField(org.firebirdsql.jdbc.field.FBFlushableField)

Example 7 with FBFlushableField

use of org.firebirdsql.jdbc.field.FBFlushableField in project jaybird by FirebirdSQL.

the class FBCachedFetcher method cacheBlobsInRow.

private static void cacheBlobsInRow(final GDSHelper gdsHelper, final RowDescriptor rowDescriptor, final boolean[] isBlob, final RowValue localRow) throws SQLException {
    // ugly blob caching workaround.
    for (int j = 0; j < localRow.getCount(); j++) {
        // if field is blob and there is a value to cache
        final byte[] tempData = localRow.getFieldData(j);
        if (isBlob[j] && tempData != null) {
            final FieldDataProvider dataProvider = new FieldDataProvider() {

                @Override
                public byte[] getFieldData() {
                    return tempData;
                }

                @Override
                public void setFieldData(byte[] data) {
                    throw new UnsupportedOperationException();
                }
            };
            // copy data from current row
            final FBFlushableField blob = (FBFlushableField) FBField.createField(rowDescriptor.getFieldDescriptor(j), dataProvider, gdsHelper, false);
            // TODO setCachedObject instead?
            localRow.setFieldData(j, blob.getCachedData());
        }
    }
}
Also used : FBFlushableField(org.firebirdsql.jdbc.field.FBFlushableField) FieldDataProvider(org.firebirdsql.jdbc.field.FieldDataProvider)

Aggregations

FBFlushableField (org.firebirdsql.jdbc.field.FBFlushableField)7 FBField (org.firebirdsql.jdbc.field.FBField)5 RowValue (org.firebirdsql.gds.ng.fields.RowValue)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 FieldValue (org.firebirdsql.gds.ng.fields.FieldValue)1 FieldDataProvider (org.firebirdsql.jdbc.field.FieldDataProvider)1