예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public InputStream getBinaryStream(long pos, long length) throws SQLException
        public Stream getBinaryStream(long pos, long length)
        {
            // JDBC 4.0 method not yet implemented

            JDBCError.throwSQLException(JDBCError.EXC_FUNCTION_NOT_SUPPORTED);
            return(null);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void checkColumn(int column) throws SQLException
        private void checkColumn(int column)
        {
            if ((column < 1) || (column > columns_.Length))
            {
                JDBCError.throwSQLException(JDBCError.EXC_DESCRIPTOR_INDEX_INVALID);
            }
        }
예제 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static int getStatementType(String sql) throws SQLException
        public static int getStatementType(string sql)
        {
            // Check for null string
            if (string.ReferenceEquals(sql, null))
            {
                JDBCError.throwSQLException(JDBCError.EXC_SYNTAX_ERROR);
            }

            string st = sql.ToUpper().Trim();


            while (st.Length > 0 && st[0] == '(')
            {
                st = st.Substring(1).Trim();
            }
            int sqlStatementType = st.StartsWith("SELECT", StringComparison.Ordinal) || st.StartsWith("VALUES", StringComparison.Ordinal) ? TYPE_SELECT : st.StartsWith("INSERT", StringComparison.Ordinal) || st.StartsWith("UPDATE", StringComparison.Ordinal) || st.StartsWith("DELETE", StringComparison.Ordinal) ? TYPE_INSERT_UPDATE_DELETE : st.StartsWith("CALL", StringComparison.Ordinal) ? TYPE_CALL : st.StartsWith("COMMIT", StringComparison.Ordinal) ? TYPE_COMMIT : st.StartsWith("ROLLBACK", StringComparison.Ordinal) ? TYPE_ROLLBACK : st.StartsWith("CONNECT", StringComparison.Ordinal) || st.StartsWith("SET", StringComparison.Ordinal) || st.StartsWith("RELEASE", StringComparison.Ordinal) || st.StartsWith("DISCONNECT", StringComparison.Ordinal) ? TYPE_CONNECT : st.StartsWith("BLOCKED INSERT", StringComparison.Ordinal) ? TYPE_BLOCKED_INSERT : TYPE_UNKNOWN;


            // Check for statement too long
            if (st.Length > (2097152 / 2))
            {
                JDBCError.throwSQLException(JDBCError.EXC_SQL_STATEMENT_TOO_LONG);
            }
            return(sqlStatementType);
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void checkRequest() throws SQLException
        private void checkRequest()
        {
            if (statement_.Closed)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void checkOpen() throws SQLException
        private void checkOpen()
        {
            if (Closed)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_CONNECTION_NONE);
            }
        }
예제 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public JDBCPreparedStatement(JDBCConnection conn, String sql, java.util.Calendar calendar, String statementName, String cursorName, int rpbID) throws SQLException
        public JDBCPreparedStatement(JDBCConnection conn, string sql, DateTime calendar, string statementName, string cursorName, int rpbID) : base(conn, statementName, cursorName, rpbID)
        {
            poolable_ = true;
            if (string.ReferenceEquals(sql, null))
            {
                JDBCError.throwSQLException(JDBCError.EXC_SYNTAX_ERROR);
                return;
            }
            rsmd_ = null;
            // Check for null statement

            DatabaseRequestAttributes dpa = new DatabaseRequestAttributes();

            //    dpa.setDescribeOption(0xD5); // Name/alias.
            //
            // Only set the statement name and cursor name in the RPB
            //
            sqlStatementType_ = JDBCStatement.getStatementType(sql);

            statementAttributes_.SQLStatementType = sqlStatementType_;

            dpa.SQLStatementType = sqlStatementType_;
            dpa.PrepareOption    = 0;      // Normal prepare.
            if (sqlStatementType_ == JDBCStatement.TYPE_SELECT)
            {                              // Only set for select statement
                dpa.OpenAttributes = 0x80; // Read only. Otherwise blocking doesn't work.
            }

            JDBCParameterMetaData pmd = new JDBCParameterMetaData(calendar);
            string catalog            = conn_.Catalog;
            // Getting the catalog may change the current rpb for the connection.
            // Reset it after getting back.  Otherwise the call to
            // prepareAndDescribe may fail with a PWS0001

            DatabaseConnection databaseConn = conn_.DatabaseConnection;

            databaseConn.CurrentRequestParameterBlockID = rpbID_;
            rsmd_ = new JDBCResultSetMetaData(conn.DatabaseInfo.ServerCCSID, calendar, catalog);

            dpa.ExtendedSQLStatementText = sql;
            conn.prepareAndDescribe(dpa, rsmd_, pmd);

            int handle = -1;
            // Only change the descriptor if there are parameters available
            DatabaseChangeDescriptorAttributes cda = (DatabaseChangeDescriptorAttributes)dpa;

            sbyte[] b = pmd.ExtendedSQLParameterMarkerDataFormat;
            cda.ExtendedSQLParameterMarkerDataFormat = b;
            handle = b == null ? -1 : conn.NextDescriptorHandle;
            if (handle >= 0)
            {
                conn.changeDescriptor(cda, handle);
            }


            pmd_              = pmd;
            pmd_.Statement    = this;
            descriptorHandle_ = handle;
        }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int executeUpdate() throws SQLException
        public virtual int executeUpdate()
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }

            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            DatabaseExecuteAttributes dea = RequestAttributes;

            dea.PrepareStatementName = statementName_;

            if (pmd_.ParameterCount > 0)
            {
                sbyte[] pmData = ExtendedParameterMarkerData;
                dea.SQLExtendedParameterMarkerData = pmData;
            }

            if (statementAttributes_.SQLStatementType == 3)
            {     // if call
                dea.SQLStatementType = 3;
            }
            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                if (currentResultSet_ != null)
                {
                    currentResultSet_.close();
                    currentResultSet_ = null;
                }
                //      conn.setSQLCommunicationsAreaCallback(this);
                try
                {
                    updateCount_ = 0;
                    if (descriptorHandle_ < 0)
                    {
                        conn.execute(dea);
                    }
                    else
                    {
                        conn.execute(dea, descriptorHandle_);
                    }
                    updateCount_ = lastUpdateCount_;
                }
                finally
                {
                    //        conn.setSQLCommunicationsAreaCallback(null);
                }

                return(updateCount_);
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }
        }
예제 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void checkRequest(int param) throws SQLException
        private void checkRequest(int param)
        {
            checkRequest();

            if (columns_ == null || (param < 1) || (param > columns_.Length))
            {
                throw JDBCError.getSQLException(JDBCError.EXC_DESCRIPTOR_INDEX_INVALID);
            }
        }
예제 #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException
        public virtual int executeUpdate(string sql, int autoGeneratedKeys)
        {
            if (closed_)
            {
                JDBCError.throwSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            if (currentResultSet_ != null)
            {
                currentResultSet_.close();
                currentResultSet_ = null;
            }
            // Check statement
            getStatementType(sql);

            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            DatabasePrepareAndExecuteAttributes pea = RequestAttributes;

            pea.ExtendedSQLStatementText = sql;
            pea.OpenAttributes           = 0x80;
            pea.DescribeOption           = 0xD5;
            pea.ScrollableCursorFlag     = 0;

            /*
             * switch (autoGeneratedKeys) { case Statement.NO_GENERATED_KEYS:
             * conn.setSQLCommunicationsAreaCallback(null); break; case
             * Statement.RETURN_GENERATED_KEYS:
             * conn.setSQLCommunicationsAreaCallback(this); break; default: throw
             * new SQLException("Bad value for autoGeneratedKeys parameter"); }
             */
            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                generatedKey_ = null;
                updateCount_  = 0;
                conn.SQLCommunicationsAreaCallback = this;
                try
                {
                    conn.prepareAndExecute(pea, null);
                    updateCount_ = lastUpdateCount_;
                }
                finally
                {
                    // conn.setSQLCommunicationsAreaCallback(null);
                }
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }
            finally
            {
                // conn.setSQLCommunicationsAreaCallback(null);
            }
            return(updateCount_);
        }
예제 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setURL(int parameterIndex, java.net.URL x) throws SQLException
        public virtual void setURL(int parameterIndex, Uri x)
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            Column col = pmd_.getColumn(parameterIndex - 1);

            col.Value = x;
        }
예제 #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setUnicodeStream(int parameterIndex, java.io.InputStream x, int length) throws SQLException
        public virtual void setUnicodeStream(int parameterIndex, Stream x, int length)
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            Column col = pmd_.getColumn(parameterIndex - 1);

            col.setUnicodeStreamValue(x, length);
        }
예제 #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException
        public virtual void setNull(int parameterIndex, int sqlType, string typeName)
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }

            Column col = pmd_.getColumn(parameterIndex - 1);

            col.Null = true;
        }
예제 #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void clearParameters() throws SQLException
        public virtual void clearParameters()
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }

            for (int i = 0; i < pmd_.ParameterCount; ++i)
            {
                Column col = pmd_.getColumn(i);
                col.clearValue();
            }
        }
예제 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setTimestamp(int parameterIndex, Timestamp x, java.util.Calendar cal) throws SQLException
        public virtual void setTimestamp(int parameterIndex, Timestamp x, DateTime cal)
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            if (cal == null)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_ATTRIBUTE_VALUE_INVALID, "cal is null");
            }
            Column col = pmd_.getColumn(parameterIndex - 1);

            col.setValue(x, cal);
        }
예제 #15
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void setDate(int parameterIndex, Date x, java.util.Calendar cal) throws SQLException
        public virtual void setDate(int parameterIndex, DateTime x, DateTime cal)
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            if (cal == null)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_PARAMETER_TYPE_INVALID, "cal is null");
            }

            Column col = pmd_.getColumn(parameterIndex - 1);

            col.setValue(x, cal);
        }
예제 #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ResultSet executeQuery(String sql) throws SQLException
        public virtual ResultSet executeQuery(string sql)
        {
            if (closed_)
            {
                JDBCError.throwSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            if (currentResultSet_ != null)
            {
                currentResultSet_.close();
                currentResultSet_ = null;
            }
            if (string.ReferenceEquals(catalog_, null))
            {
                catalog_ = conn_.Catalog;
            }

            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            //      DatabasePrepareAttributes pea = getRequestAttributes(); //conn_.getRequestAttributes();
            DatabasePrepareAndDescribeAttributes pea = RequestAttributes;

            pea.ExtendedSQLStatementText = sql;
            //      pea.setPrepareOption(0x01); // Enhanced.


            // Verify that the statement could return a result set

            int statementType = getStatementType(sql);

            switch (statementType)
            {
            case TYPE_SELECT:
                // Only request extended column descriptor for select statements (not call )
                pea.OpenAttributes = 0x80;
                pea.ExtendedColumnDescriptorOption = 0xF1;
                goto case TYPE_CALL;

            case TYPE_CALL:
                break;

            default:
                // Not a query -- throw an exception
                throw new SQLException("Not a query");
            }
            pea.SQLStatementType = statementType;     // SELECT. This has to be set in order to get extended column metadata back.
            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                generatedKey_ = null;

                //        conn.prepare(pea);
                JDBCResultSetMetaData md = new JDBCResultSetMetaData(conn.Info.ServerCCSID, conn_.Calendar, catalog_);
                conn.prepareAndDescribe(pea, md, null);   // Just a plain prepare doesn't give us extended column metadata back.


                if (statementType == TYPE_SELECT)
                {
                    DatabaseOpenAndDescribeAttributes oada = (DatabaseOpenAndDescribeAttributes)pea;
                    if (fetchSize_ > 0)
                    {
                        oada.BlockingFactor = fetchSize_;
                    }
                    oada.DescribeOption           = 0xD5;
                    oada.ScrollableCursorFlag     = 0;
                    oada.VariableFieldCompression = 0xe8;
                    conn.openAndDescribe(oada, null);
                    currentResultSet_ = new JDBCResultSet(this, md, statementName_, cursorName_, fetchSize_);
                    updateCount_      = -1;
                    return(currentResultSet_);
                }
                else
                {
                    DatabaseExecuteAttributes dea = RequestAttributes;

                    // Flags set by normal toolbox
                    ((DatabaseOpenAndDescribeAttributes)dea).ScrollableCursorFlag       = 0;
                    ((DatabaseOpenAndDescribeAttributes)dea).ResultSetHoldabilityOption = 0xe8;             // Y
                    ((DatabaseOpenAndDescribeAttributes)dea).VariableFieldCompression   = 0xe8;
                    if (fetchSize_ > 0)
                    {
                        ((DatabaseOpenAndDescribeAttributes)dea).BlockingFactor = fetchSize_;
                    }


                    dea.SQLStatementType = JDBCStatement.TYPE_CALL;

                    conn.execute(dea);


                    // TODO:  Determine if result set is available from the call.  If so, then call openDescribe using the existing cursor name if it exists
                    if (resultSetsCount_ > 0)
                    {
                        DatabaseOpenAndDescribeAttributes oada = RequestAttributes;


                        oada.OpenAttributes           = 0x80;
                        oada.ScrollableCursorFlag     = 0;
                        oada.VariableFieldCompression = 0xe8;
                        if (string.ReferenceEquals(catalog_, null))
                        {
                            catalog_ = conn_.Catalog;
                        }

                        md = new JDBCResultSetMetaData(conn.Info.ServerCCSID, conn_.Calendar, catalog_);

                        conn.CurrentRequestParameterBlockID = rpbID_;
                        if (currentResultSet_ != null)
                        {
                            currentResultSet_.close();
                            currentResultSet_ = null;
                        }
                        conn.openAndDescribe(oada, md);

                        currentResultSet_ = new JDBCResultSet(this, md, statementName_, cursorName_, fetchSize_);
                        updateCount_      = -1;

                        return(currentResultSet_);
                    }
                    else
                    {
                        // Did not return result set
                        JDBCError.throwSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
                        return(null);
                    }
                }
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }
        }
예제 #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean execute(String sql, int autoGeneratedKeys) throws SQLException
        public virtual bool execute(string sql, int autoGeneratedKeys)
        {
            if (closed_)
            {
                JDBCError.throwSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }
            if (currentResultSet_ != null)
            {
                currentResultSet_.close();
                currentResultSet_ = null;
            }

            int statementType = getStatementType(sql);

            if (statementType == TYPE_SELECT)
            {
                currentResultSet_ = (JDBCResultSet)executeQuery(sql);
                return(true);
            }


            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            DatabaseExecuteImmediateAttributes deia = RequestAttributes;     //conn_.getRequestAttributes();

            deia.SQLStatementText = sql;

            if (statementType == TYPE_CALL)
            {
                deia.SQLStatementType = TYPE_CALL;
                deia.OpenAttributes   = 0x80; // READ
                deia.PrepareOption    = 0;    // normal prepare
            }

            /*    switch (autoGeneratedKeys)
             *  {
             *    case Statement.NO_GENERATED_KEYS:
             *      conn.setSQLCommunicationsAreaCallback(null);
             *      break;
             *    case Statement.RETURN_GENERATED_KEYS:
             *      conn.setSQLCommunicationsAreaCallback(this);
             *      break;
             *    default:
             *      throw new SQLException("Bad value for autoGeneratedKeys parameter");
             *  }
             */
            bool resultSetAvailable = false;

            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                generatedKey_ = null;
                conn.executeImmediate(deia);
                updateCount_ = lastUpdateCount_;
                //
                // Todo:  Need to check for result sets
                //
                if (resultSetsCount_ > 0)
                {
                    resultSetAvailable = true;
                    DatabaseOpenAndDescribeAttributes oada = RequestAttributes;


                    oada.OpenAttributes           = 0x80;
                    oada.ScrollableCursorFlag     = 0;
                    oada.VariableFieldCompression = 0xe8;
                    if (string.ReferenceEquals(catalog_, null))
                    {
                        catalog_ = conn_.Catalog;
                    }

                    JDBCResultSetMetaData md = new JDBCResultSetMetaData(conn.Info.ServerCCSID, conn_.Calendar, catalog_);

                    try
                    {
                        conn.CurrentRequestParameterBlockID = rpbID_;
                        if (currentResultSet_ != null)
                        {
                            currentResultSet_.close();
                            currentResultSet_ = null;
                        }
                        conn.openAndDescribe(oada, md);
                    }
                    catch (IOException io)
                    {
                        throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
                    }
                    currentResultSet_ = new JDBCResultSet(this, md, statementName_, cursorName_, fetchSize_);
                    updateCount_      = -1;
                }
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }
            finally
            {
                //      conn.setSQLCommunicationsAreaCallback(null);
            }
            return(resultSetAvailable);
        }
예제 #18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean execute() throws SQLException
        public virtual bool execute()
        {
            bool callStatement = false;

            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }


            //
            // If this is a select statement, use the executeQuery path
            //
            if (sqlStatementType_ == JDBCStatement.TYPE_SELECT)
            {     // Only set for select statement
                executeQuery();
                return(true);
            }

            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            DatabaseExecuteAttributes dea = RequestAttributes;

            // Not necessary -- part of RPB
            // dea.setPrepareStatementName(statementName_);

            // Flags set by normal toolbox
            ((DatabaseOpenAndDescribeAttributes)dea).ScrollableCursorFlag       = 0;
            ((DatabaseOpenAndDescribeAttributes)dea).ResultSetHoldabilityOption = 0xe8;   // Y
            ((DatabaseOpenAndDescribeAttributes)dea).VariableFieldCompression   = 0xe8;   // Y


            if (statementAttributes_.SQLStatementType == JDBCStatement.TYPE_CALL)
            {     // if call
                dea.SQLStatementType = JDBCStatement.TYPE_CALL;
                callStatement        = true;
            }



            if (pmd_.ParameterCount > 0)
            {
                sbyte[] pmData = ExtendedParameterMarkerData;
                dea.SQLExtendedParameterMarkerData = pmData;
            }


            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                if (currentResultSet_ != null)
                {
                    currentResultSet_.close();
                    currentResultSet_ = null;
                }
                //      conn.setSQLCommunicationsAreaCallback(returnGeneratedKeys_ ? this : null);
                updateCount_ = 0;
                if (descriptorHandle_ < 0)
                {
                    conn.execute(dea);
                }
                else
                {
                    conn.execute(dea, descriptorHandle_);
                }
                updateCount_ = lastUpdateCount_;

                // TODO:  Determine if result set is available.  If so, then call openDescribe
                if (callStatement && resultSetsCount_ > 0)
                {
                    DatabaseOpenAndDescribeAttributes oada = RequestAttributes;

                    oada.OpenAttributes           = 0x80;
                    oada.ScrollableCursorFlag     = 0;
                    oada.VariableFieldCompression = 0xe8;
                    JDBCResultSetMetaData md = new JDBCResultSetMetaData(conn.Info.ServerCCSID, conn_.Calendar, conn_.Catalog);

                    try
                    {
                        conn.CurrentRequestParameterBlockID = rpbID_;
                        if (currentResultSet_ != null)
                        {
                            currentResultSet_.close();
                            currentResultSet_ = null;
                        }
                        if (descriptorHandle_ < 0)
                        {
                            conn.openAndDescribe(oada, md);
                        }
                        else
                        {
                            conn.openAndDescribe(oada, descriptorHandle_, md);
                        }
                    }
                    catch (IOException io)
                    {
                        throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
                    }

                    currentResultSet_ = new JDBCResultSet(this, md, statementName_, cursorName_, fetchSize_);
                    updateCount_      = -1;
                }
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }
            finally
            {
                //      conn.setSQLCommunicationsAreaCallback(null);
            }
            return(true);
        }
예제 #19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public ResultSet executeQuery() throws SQLException
        public virtual ResultSet executeQuery()
        {
            if (closed_)
            {
                throw JDBCError.getSQLException(JDBCError.EXC_FUNCTION_SEQUENCE);
            }

            switch (sqlStatementType_)
            {
            case JDBCStatement.TYPE_SELECT:
                // Valid
                break;

            case JDBCStatement.TYPE_CALL:
            {
                bool result = execute();
                if (result)
                {
                    ResultSet rs = ResultSet;
                    if (rs == null)
                    {
                        throw JDBCError.getSQLException(JDBCError.EXC_CURSOR_STATE_INVALID);
                    }
                    else
                    {
                        return(rs);
                    }
                }
                else
                {
                    throw JDBCError.getSQLException(JDBCError.EXC_CURSOR_STATE_INVALID);
                }
            }
                goto default;

            default:
                throw JDBCError.getSQLException(JDBCError.EXC_CURSOR_STATE_INVALID);
            }

            if (currentResultSet_ != null)
            {
                currentResultSet_.close();
                currentResultSet_ = null;
            }


            DatabaseConnection conn = conn_.DatabaseConnection;

            conn.SQLCommunicationsAreaCallback = this;
            DatabaseOpenAndDescribeAttributes dea = RequestAttributes;     //conn_.getRequestAttributes();

            dea.PrepareStatementName = statementName_;
            if (string.ReferenceEquals(cursorName_, null))
            {
                cursorName_ = conn_.NextCursorName;
            }
            dea.CursorName = cursorName_;
            if (fetchSize_ > 0)
            {
                dea.BlockingFactor = fetchSize_;
            }
            dea.DescribeOption           = 0xD5;
            dea.ScrollableCursorFlag     = 0;
            dea.VariableFieldCompression = 0xe8;

            if (descriptorHandle_ >= 0)
            {
                sbyte[] pmData = ExtendedParameterMarkerData;
                dea.SQLExtendedParameterMarkerData = pmData;
            }
            JDBCResultSetMetaData md = new JDBCResultSetMetaData(conn.Info.ServerCCSID, conn_.Calendar, conn_.Catalog);

            try
            {
                conn.CurrentRequestParameterBlockID = rpbID_;
                if (descriptorHandle_ < 0)
                {
                    conn.openAndDescribe(dea, md);
                }
                else
                {
                    conn.openAndDescribe(dea, descriptorHandle_, md);
                }
            }
            catch (IOException io)
            {
                throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_);
            }

            currentResultSet_ = new JDBCResultSet(this, md, statementName_, cursorName_, fetchSize_);
            return(currentResultSet_);
        }