/// <summary> /// Provides the core logic for the <see cref="Prepare()"/> method. /// </summary> internal void PrepareInternal() { if (!IsPrepared) { string sql; HsqlSession session = this.Session; switch (m_commandType) { case CommandType.StoredProcedure: { sql = StoredProcedureCommandText; break; } case CommandType.Text: { sql = DefaultParameterMarkerCommandText; break; } case CommandType.TableDirect: { sql = TableDirectCommandText; break; } default: { throw new HsqlDataSourceException( "CommandType not supported: " + m_commandType); // NOI18N } } m_statement = session.PrepareStatement(sql); // no longer valid m_commandTextBatch = null; } }
/// <summary> /// Releases, if present, the underlying <c>HsqlStatement</c> and /// makes eligible for garbage collection any related resources. /// </summary> internal void InvalidateStatement() { try { // localize member references to minimize // potential race conditions regarding // null status of instance variables. HsqlConnection connection = m_dbConnection; HsqlStatement statement = m_statement; // Don't leak compiled statement handles if (connection != null && connection.State == ConnectionState.Open && statement != null) { statement.Free(Session); } } finally { m_statement = null; m_tokenList = null; m_storedProcedureCommandText = null; m_tableDirectCommandText = null; } }