Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
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_);
            }
        }
Пример #4
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);
            }
        }
Пример #5
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;
        }
Пример #6
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);
        }
Пример #7
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;
        }
Пример #8
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();
            }
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
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_);
        }
Пример #12
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);
        }