Search in sources :

Example 31 with XdrOutputStream

use of org.firebirdsql.gds.impl.wire.XdrOutputStream in project jaybird by FirebirdSQL.

the class V10Statement method sendAllocate.

/**
 * Sends the allocate request to the server.
 *
 * @throws SQLException
 * @throws IOException
 */
protected void sendAllocate() throws SQLException, IOException {
    final XdrOutputStream xdrOut = getXdrOut();
    xdrOut.writeInt(WireProtocolConstants.op_allocate_statement);
    xdrOut.writeInt(getDatabase().getHandle());
}
Also used : XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream)

Example 32 with XdrOutputStream

use of org.firebirdsql.gds.impl.wire.XdrOutputStream in project jaybird by FirebirdSQL.

the class V10Statement method writeSqlData.

/**
 * Write a set of SQL data from a list of {@link FieldValue} instances.
 *
 * @param rowDescriptor
 *         The row descriptor
 * @param fieldValues
 *         The List containing the SQL data to be written
 * @throws IOException
 *         if an error occurs while writing to the underlying output stream
 */
protected void writeSqlData(final RowDescriptor rowDescriptor, final RowValue fieldValues) throws IOException, SQLException {
    final XdrOutputStream xdrOut = getXdrOut();
    final BlrCalculator blrCalculator = getDatabase().getBlrCalculator();
    for (int idx = 0; idx < fieldValues.getCount(); idx++) {
        final FieldValue fieldValue = fieldValues.getFieldValue(idx);
        final FieldDescriptor fieldDescriptor = rowDescriptor.getFieldDescriptor(idx);
        final int len = blrCalculator.calculateIoLength(fieldDescriptor, fieldValue);
        final byte[] buffer = fieldValue.getFieldData();
        final int fieldType = fieldDescriptor.getType();
        writeColumnData(xdrOut, len, buffer, fieldType);
        // sqlind (null indicator)
        xdrOut.writeInt(buffer != null ? NULL_INDICATOR_NOT_NULL : NULL_INDICATOR_NULL);
    }
}
Also used : XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream)

Example 33 with XdrOutputStream

use of org.firebirdsql.gds.impl.wire.XdrOutputStream in project jaybird by FirebirdSQL.

the class V10Statement method sendFree.

/**
 * Sends the free statement to the database
 *
 * @param option
 *         Free statement option
 * @throws IOException
 * @throws SQLException
 */
protected void sendFree(int option) throws IOException, SQLException {
    final XdrOutputStream xdrOut = getXdrOut();
    xdrOut.writeInt(WireProtocolConstants.op_free_statement);
    xdrOut.writeInt(getHandle());
    xdrOut.writeInt(option);
}
Also used : XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream)

Example 34 with XdrOutputStream

use of org.firebirdsql.gds.impl.wire.XdrOutputStream in project jaybird by FirebirdSQL.

the class V10Statement method sendInfoSql.

/**
 * Sends the info sql request to the database
 *
 * @param requestItems
 *         Info request items
 * @param bufferLength
 *         Requested response buffer length
 * @throws IOException
 * @throws SQLException
 */
protected void sendInfoSql(final byte[] requestItems, final int bufferLength) throws IOException, SQLException {
    final XdrOutputStream xdrOut = getXdrOut();
    xdrOut.writeInt(WireProtocolConstants.op_info_sql);
    xdrOut.writeInt(getHandle());
    // incarnation
    xdrOut.writeInt(0);
    xdrOut.writeBuffer(requestItems);
    xdrOut.writeInt(bufferLength);
}
Also used : XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream)

Example 35 with XdrOutputStream

use of org.firebirdsql.gds.impl.wire.XdrOutputStream in project jaybird by FirebirdSQL.

the class V10Statement method sendFetch.

/**
 * Sends the fetch request to the database.
 *
 * @param fetchSize Number of rows to fetch.
 * @throws SQLException
 * @throws IOException
 */
protected void sendFetch(int fetchSize) throws SQLException, IOException {
    final XdrOutputStream xdrOut = getXdrOut();
    xdrOut.writeInt(WireProtocolConstants.op_fetch);
    xdrOut.writeInt(getHandle());
    xdrOut.writeBuffer(calculateBlr(getFieldDescriptor()));
    // out_message_number = out_message_type
    xdrOut.writeInt(0);
    // fetch size
    xdrOut.writeInt(fetchSize);
}
Also used : XdrOutputStream(org.firebirdsql.gds.impl.wire.XdrOutputStream)

Aggregations

XdrOutputStream (org.firebirdsql.gds.impl.wire.XdrOutputStream)41 SQLException (java.sql.SQLException)25 IOException (java.io.IOException)24 FbExceptionBuilder (org.firebirdsql.gds.ng.FbExceptionBuilder)22 SimpleServer (org.firebirdsql.common.SimpleServer)4 Encoding (org.firebirdsql.encodings.Encoding)3 XdrInputStream (org.firebirdsql.gds.impl.wire.XdrInputStream)3 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 SQLNonTransientConnectionException (java.sql.SQLNonTransientConnectionException)2 SQLNonTransientException (java.sql.SQLNonTransientException)2 BlobParameterBuffer (org.firebirdsql.gds.BlobParameterBuffer)2 GenericResponse (org.firebirdsql.gds.ng.wire.GenericResponse)2 SQLFeatureNotSupportedException (java.sql.SQLFeatureNotSupportedException)1 SQLTimeoutException (java.sql.SQLTimeoutException)1 BitSet (java.util.BitSet)1 WireCrypt (org.firebirdsql.gds.ng.WireCrypt)1 ClientAuthBlock (org.firebirdsql.gds.ng.wire.auth.ClientAuthBlock)1 EncryptionIdentifier (org.firebirdsql.gds.ng.wire.crypt.EncryptionIdentifier)1