Search in sources :

Example 6 with XdrInputStream

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

the class AbstractWireOperations method readStatusVector.

@Override
public final SQLException readStatusVector() throws SQLException {
    boolean debug = log.isDebugEnabled();
    final FbExceptionBuilder builder = new FbExceptionBuilder();
    final XdrInputStream xdrIn = getXdrIn();
    try {
        while (true) {
            int arg = xdrIn.readInt();
            int errorCode;
            switch(arg) {
                case isc_arg_gds:
                    errorCode = xdrIn.readInt();
                    if (debug)
                        log.debug("readStatusVector arg:isc_arg_gds int: " + errorCode);
                    if (errorCode != 0) {
                        builder.exception(errorCode);
                    }
                    break;
                case isc_arg_warning:
                    errorCode = xdrIn.readInt();
                    if (debug)
                        log.debug("readStatusVector arg:isc_arg_warning int: " + errorCode);
                    if (errorCode != 0) {
                        builder.warning(errorCode);
                    }
                    break;
                case isc_arg_interpreted:
                case isc_arg_string:
                    String stringValue = xdrIn.readString(getEncoding());
                    if (debug)
                        log.debug("readStatusVector string: " + stringValue);
                    builder.messageParameter(stringValue);
                    break;
                case isc_arg_sql_state:
                    String sqlState = xdrIn.readString(getEncoding());
                    if (debug)
                        log.debug("readStatusVector sqlstate: " + sqlState);
                    builder.sqlState(sqlState);
                    break;
                case isc_arg_number:
                    int intValue = xdrIn.readInt();
                    if (debug)
                        log.debug("readStatusVector arg:isc_arg_number int: " + intValue);
                    builder.messageParameter(intValue);
                    break;
                case isc_arg_end:
                    if (builder.isEmpty()) {
                        return null;
                    }
                    return builder.toFlatSQLException();
                default:
                    int e = xdrIn.readInt();
                    if (debug)
                        log.debug("readStatusVector arg: " + arg + " int: " + e);
                    builder.messageParameter(e);
                    break;
            }
        }
    } catch (IOException ioe) {
        throw new FbExceptionBuilder().exception(ISCConstants.isc_net_read_err).cause(ioe).toSQLException();
    }
}
Also used : XdrInputStream(org.firebirdsql.gds.impl.wire.XdrInputStream) FbExceptionBuilder(org.firebirdsql.gds.ng.FbExceptionBuilder) IOException(java.io.IOException)

Aggregations

XdrInputStream (org.firebirdsql.gds.impl.wire.XdrInputStream)6 XdrOutputStream (org.firebirdsql.gds.impl.wire.XdrOutputStream)3 FbExceptionBuilder (org.firebirdsql.gds.ng.FbExceptionBuilder)3 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 Encoding (org.firebirdsql.encodings.Encoding)2 SQLTimeoutException (java.sql.SQLTimeoutException)1 BitSet (java.util.BitSet)1 WireCrypt (org.firebirdsql.gds.ng.WireCrypt)1 GenericResponse (org.firebirdsql.gds.ng.wire.GenericResponse)1 ClientAuthBlock (org.firebirdsql.gds.ng.wire.auth.ClientAuthBlock)1 EncryptionIdentifier (org.firebirdsql.gds.ng.wire.crypt.EncryptionIdentifier)1