Пример #1
0
 /// <summary>
 /// Executes this statement in the context of the given session,
 /// returning a single, scalar value.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// a scalar value.
 /// </returns>
 internal object ExecuteScalar(HsqlSession session)
 {
     return(session.ExecuteScalarPrepared(m_request));
 }
Пример #2
0
 /// <summary>
 /// Notifies the given session that it
 /// may release any resources dedicated
 /// to maintaing the prepared form of
 /// this statement.
 /// </summary>
 /// <param name="session">To notify</param>
 internal void Free(HsqlSession session)
 {
     session.FreeStatement(m_statementId);
 }
Пример #3
0
 /// <summary>
 /// Executes a batch request in the context of the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// </returns>
 internal int[] ExecuteBatch(HsqlSession session)
 {
     return(session.Execute(m_batchRequest).getUpdateCounts());
 }
Пример #4
0
 /// <summary>
 /// Executes this statement in the context of the given session,
 /// returning the number of rows affected.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>The number of rows affected.</returns>
 internal int ExecuteNonQuery(HsqlSession session)
 {
     return(session.ExecuteNonQueryPrepared(m_request));
 }
 /// <summary>
 /// Notifies the given session that it
 /// may release any resources dedicated
 /// to maintaing the prepared form of
 /// this statement.
 /// </summary>
 /// <param name="session">To notify</param>
 internal void Free(HsqlSession session)
 {
     session.FreeStatement(m_statementId);
 }
Пример #6
0
 /// <summary>
 /// Executes this statement in the context of the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// A response encapsulating the result of execution.
 /// </returns>
 internal Response Execute(HsqlSession session)
 {
     return(session.Execute(m_request));
 }
 /// <summary>
 /// Executes this statement in the context of the given session,
 /// returning the number of rows affected.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>The number of rows affected.</returns>
 internal int ExecuteNonQuery(HsqlSession session)
 {
     return session.ExecuteNonQueryPrepared(m_request);
 }
 /// <summary>
 /// Executes this statement in the context of the given session,
 /// returning a single, scalar value.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// a scalar value.
 /// </returns>
 internal object ExecuteScalar(HsqlSession session)
 {
     return session.ExecuteScalarPrepared(m_request);
 }
 /// <summary>
 /// Executes a batch request in the context of the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// </returns>
 internal int[] ExecuteBatch(HsqlSession session)
 {
     return session.Execute(m_batchRequest).getUpdateCounts();
 }
 /// <summary>
 /// Executes this statement in the context of the specified session.
 /// </summary>
 /// <param name="session">The session.</param>
 /// <returns>
 /// A response encapsulating the result of execution.
 /// </returns>
 internal Response Execute(HsqlSession session)
 {
     return session.Execute(m_request);
 }
        void OpenSessionTimeout(int timeout)
        {
            Exception se = null;
            Thread thread = new Thread(delegate()
            {
                try
                {
                    OpenSessionNoTimeout();
                }
                catch (Exception ex)
                {
                    se = ex;
                }
            });

            try
            {
                thread.Start();
                thread.Join(timeout);
            }
            catch (Exception)
            {
                m_session = null;
                SetStateInternal(ConnectionState.Closed);
                throw;
            }

            if (se != null)
            {
                m_session = null;
                SetStateInternal(ConnectionState.Closed);
                throw se;
            }
            else if (m_session == null)
            {
                SetStateInternal(ConnectionState.Closed);
                throw new TimeoutException(string.Format(
                    "Connection attempt aborted after {0} milliseconds",
                    (timeout == Threading.Timeout.Infinite) ? "Infinite"
                    : timeout.ToString("N")));
            }
        }
        private void OpenSessionNoTimeout()
        {
            SetStateInternal(ConnectionState.Connecting);

            try
            {
                m_session = HsqlDriver.GetSession(m_settings);
                SetStateInternal(ConnectionState.Open);
            #if SYSTRAN
                if (m_settings.Enlist)
                {

                    Transaction tx = Transaction.Current;

                    if (tx != null)
                    {
                        EnlistTransaction(tx);
                    }
                }
            #endif
            }
            catch (Exception)
            {
                m_session = null;
                SetStateInternal(ConnectionState.Closed);
                throw;
            }
        }
        /// <summary>
        /// Closes this connection.
        /// </summary>
        internal void CloseInternal()
        {
            ConnectionState state = m_connectionState;

            if (state == ConnectionState.Closed)
            {
                return;
            }

            HsqlSession session = m_session;

            if (m_session == null)
            {
                // Sanity-Check: Should never happen.
                throw new InvalidOperationException(
                    "HsqlSession is null"); // NOI18N
            }

            // Handle dispose/close while enlisted in a system transaction.

            HsqlTransaction transaction = m_transaction;
            HsqlEnlistment enlistment = m_enlistment;

            bool enlisted = (enlistment != null);
            bool preserveEnlistment = (enlisted && !enlistment.m_disposeConnection);

            if (preserveEnlistment)
            {
            #if DEBUG
                // Without this, it is difficult to debug
                // because the m_enlistment's connection
                // ceases to be this one and this connection
                // loses its reference to the enlistment
                // (m_enlistment is set null below).
                m_enlistment_dbg = m_enlistment;
            #endif
                // ...then until it ceases to participate in a
                // System.Transactions.Transaction, the enlistment
                // needs a valid local transaction to commit or
                // rollback

                HsqlConnection connection = new HsqlConnection(this);

                connection.m_connectionState = ConnectionState.Open;
                connection.m_session = session;
                connection.m_enlistment = enlistment;
                connection.m_transaction = transaction;

                enlistment.m_dbConnection = connection;
                enlistment.m_disposeConnection = true;

                if (transaction != null)
                {
                    transaction.m_connection = connection;
                }
            }

            SetStateInternal(ConnectionState.Closed);

            m_session = null;
            m_transaction = null;
            m_enlistment = null;
            m_dbMetaData = null;
            m_settings = null;

            if (!enlisted)
            {
                // No need to roll back here. This will happen automatically
                // a moment later on the back end in response to the
                // session.Close() call below.
                if (transaction != null)
                {
                    transaction.DisposeInternal(/*rollback*/false);
                }

                // release the back-end session and any associated resources,
                // such as network sockets, etc.
                session.Close();
            }
        }