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