use of org.firebirdsql.jdbc.field.FieldDataProvider in project jaybird by FirebirdSQL.
the class AbstractPreparedStatement method prepareFixedStatement.
/**
* Prepare fixed statement and initialize parameters.
*/
protected void prepareFixedStatement(String sql) throws SQLException {
super.prepareFixedStatement(sql);
RowDescriptor rowDescriptor = fbStatement.getParameterDescriptor();
assert rowDescriptor != null : "RowDescriptor should not be null after prepare";
isParamSet = new boolean[rowDescriptor.getCount()];
fieldValues = rowDescriptor.createDefaultFieldValues();
fields = new FBField[rowDescriptor.getCount()];
for (int i = 0; i < isParamSet.length; i++) {
FieldDataProvider dataProvider = fieldValues.getFieldValue(i);
// FIXME check if we can safely pass cached here
fields[i] = FBField.createField(getParameterDescriptor(i + 1), dataProvider, gdsHelper, false);
}
this.isExecuteProcedureStatement = fbStatement.getType() == StatementType.STORED_PROCEDURE;
}
use of org.firebirdsql.jdbc.field.FieldDataProvider 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
if (isBlob[j] && localRow.getFieldValue(j).getFieldData() != null) {
final byte[] tempData = localRow.getFieldValue(j).getFieldData();
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.getFieldValue(j).setFieldData(blob.getCachedData());
}
}
}
Aggregations