Search in sources :

Example 1 with FBCloseableField

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

the class FBResultSet method closeFields.

/**
 * Close the fields if they were open (applies mainly to the stream fields).
 *
 * @throws SQLException
 *         if something wrong happened.
 */
protected void closeFields() throws SQLException {
    // TODO See if we can apply completion reason logic (eg no need to close blob on commit)
    wasNullValid = false;
    // if there are no fields to close, then nothing to do
    if (closeableFields.isEmpty())
        return;
    SQLExceptionChainBuilder<SQLException> chain = new SQLExceptionChainBuilder<>();
    // close current fields, so that resources are freed.
    for (final FBCloseableField field : closeableFields) {
        try {
            field.close();
        } catch (SQLException ex) {
            chain.append(ex);
        }
    }
    if (chain.hasException()) {
        throw chain.getException();
    }
}
Also used : SQLExceptionChainBuilder(org.firebirdsql.util.SQLExceptionChainBuilder) FBCloseableField(org.firebirdsql.jdbc.field.FBCloseableField)

Example 2 with FBCloseableField

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

the class FBResultSet method prepareVars.

private void prepareVars(boolean cached) throws SQLException {
    for (int i = 0; i < rowDescriptor.getCount(); i++) {
        final int fieldPosition = i;
        FieldDataProvider dataProvider = new FieldDataProvider() {

            @Override
            public byte[] getFieldData() {
                return row.getFieldData(fieldPosition);
            }

            @Override
            public void setFieldData(byte[] data) {
                row.setFieldData(fieldPosition, data);
            }
        };
        final FBField field = FBField.createField(rowDescriptor.getFieldDescriptor(i), dataProvider, gdsHelper, cached);
        if (field instanceof FBCloseableField) {
            closeableFields.add((FBCloseableField) field);
        }
        fields[i] = field;
    }
}
Also used : FBField(org.firebirdsql.jdbc.field.FBField) FieldDataProvider(org.firebirdsql.jdbc.field.FieldDataProvider) FBCloseableField(org.firebirdsql.jdbc.field.FBCloseableField)

Aggregations

FBCloseableField (org.firebirdsql.jdbc.field.FBCloseableField)2 FBField (org.firebirdsql.jdbc.field.FBField)1 FieldDataProvider (org.firebirdsql.jdbc.field.FieldDataProvider)1 SQLExceptionChainBuilder (org.firebirdsql.util.SQLExceptionChainBuilder)1