//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_); } }
//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_); } }
//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); }