//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Connection connect(String url, Properties info) throws SQLException public virtual Connection connect(string url, Properties info) { if (acceptsURL(url)) { string system = url.Substring(18); int semi = system.IndexOf(";", StringComparison.Ordinal); if (semi >= 0) { if (info == null) { info = new Properties(); } addURLProperties(system.Substring(semi + 1), info); } int slash = system.IndexOf("/", StringComparison.Ordinal); if (semi >= 0 || slash >= 0) { int min = semi >= 0 && slash >= 0 ? (semi < slash ? semi : slash) : (semi >= 0 ? semi : slash); system = system.Substring(0, min); } system = system.Trim(); string user = info.getProperty("user"); string password = info.getProperty("password"); bool isSSL = bool.Parse(info.getProperty("secure", "false")); bool debugOn = info.getProperty("debug", "false").Equals("true"); if (Trace.StreamTracingEnabled) { debugOn = true; } return(JDBCConnection.getConnection(isSSL, system, user, password, debugOn)); } return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void close() throws SQLException public virtual void close() { if (closed_) { return; } try { generatedKey_ = null; if (currentResultSet_ != null) { currentResultSet_.close(); currentResultSet_ = null; } attribs_.clear(); conn_.DatabaseConnection.deleteRequestParameterBlock(attribs_, rpbID_); conn_.freeRPBID(rpbID_); if (!string.ReferenceEquals(statementName_, null)) { conn_.freeStatementAndCursorNames(statementName_, cursorName_); } statementName_ = null; cursorName_ = null; } catch (IOException io) { throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_); } finally { closed_ = true; } }
//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; }
//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 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_); }
internal bool poolable_ = false; // Default is false //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public JDBCStatement(JDBCConnection conn, String statementName, String cursorName, int rpbID) throws SQLException public JDBCStatement(JDBCConnection conn, string statementName, string cursorName, int rpbID) { cursorName_ = cursorName; statementName_ = statementName; if (rpbID != 0) { DatabaseRequestAttributes rpb = new DatabaseRequestAttributes(); rpb.CursorName = cursorName; rpb.PrepareStatementName = statementName; conn.createRequestParameterBlock(rpb, rpbID); attribs_ = rpb; statementAttributes_ = rpb.copy(); } conn_ = conn; rpbID_ = rpbID; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static JDBCConnection getConnection(boolean isSSL, String system, String user, String password, boolean debug) throws SQLException public static JDBCConnection getConnection(bool isSSL, string system, string user, string password, bool debug) { try { // The first boolean parameter indicates that SSL should be used. DatabaseConnection conn = DatabaseConnection.getConnection(isSSL, system, user, password); conn.MessageInfoReturned = true; conn.Debug = debug; DatabaseServerAttributes dsa = new DatabaseServerAttributes(); dsa.NamingConventionParserOption = 0; dsa.UseExtendedFormats = 0xF2; dsa.DefaultClientCCSID = 13488; dsa.DateFormatParserOption = 5; // ISO. dsa.LOBFieldThreshold = 1024 * 1024; // Use a locator for any LOB data fields longer than 1 MB. dsa.ClientSupportInformation = 0x40000000; // Client supports True autocommit dsa.InterfaceType = "JDBC"; dsa.InterfaceName = About.INTERFACE_NAME; dsa.InterfaceLevel = About.INTERFACE_LEVEL; // // Do not set any commitment control levels. // The default behavior is true auto commit = off // and a transaction isolation of *NONE. // This means that connection behaves like autocommit = on. // conn.ServerAttributes = dsa; // // Remember the serverJobIdentifier // // DatabaseRequestAttributes rpb = new DatabaseRequestAttributes(); // conn.createRequestParameterBlock(rpb); // JDBCConnection j = new JDBCConnection(conn, rpb); JDBCConnection j = new JDBCConnection(conn); conn.WarningCallback = j; j.serverJobIdentifier_ = dsa.ServerJobName + dsa.ServerJobUser + dsa.ServerJobNumber; return(j); } catch (IOException io) { throw convertException(io); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void close() throws SQLException public override void close() { if (closed_) { return; } DatabaseConnection conn = conn_.DatabaseConnection; conn.SQLCommunicationsAreaCallback = this; try { if (descriptorHandle_ >= 0) { conn.deleteDescriptor(null, descriptorHandle_); } } catch (IOException io) { throw JDBCConnection.convertException(io, lastSQLCode_, lastSQLState_); } base.close(); }
//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(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 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() 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); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public JDBCCallableStatement(JDBCConnection conn, String sql, java.util.Calendar calendar, String statementName, String cursorName, int rpbID) throws java.sql.SQLException public JDBCCallableStatement(JDBCConnection conn, string sql, DateTime calendar, string statementName, string cursorName, int rpbID) : base(conn, sql, calendar, statementName, cursorName, rpbID) { }