public virtual DBResult Execute(DatabaseConnection conn, QueryString sql, DatabaseParameterList parms) { throw new NotImplementedException("Execute not implemented in base class"); }
public override DBResult Query(DatabaseConnection conn, QueryString sql, out DatabaseDataReader reader, int timeout = 30) { return(Query(conn, sql, null, out reader, timeout)); }
public DBResult Update(QueryString sql, OdbcParameterList parameterDictionary) { if (ReadOnly) { throw new DataSourceException("{0} is read-only", this); } DatabaseConnection connection; DBResult result = GetConnection(out connection); result = Update(connection, sql, parameterDictionary); if (result.ResultCode == DBResult.Result.ConnectionDropped) { /** If the connection was lost during the query, we will perform retry logic */ int retriesLeft = connection.ConnectionRetries; do { Log.LogText(LogLevel.WARNING, "The connection was found to be dropped - will retry {0} of {1}", retriesLeft, connection.ConnectionRetries); /** lose the old connection and obtain a new one */ if (connection != null) { _connectionPool.DropConnection(connection); } if ((result = GetConnection(out connection)).ResultCode == DBResult.Result.Success) { #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.UpdateTimer.Start(sql.ToString()); } #endif result = Update(connection, sql, parameterDictionary); #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.UpdateTimer.Stop(); } #endif } else { connection = null; } if (connection != null && connection.ConnectionRetryInterval != TimeSpan.Zero) { Thread.Sleep(connection.ConnectionRetryInterval); } } while (result.ResultCode == DBResult.Result.ConnectionDropped && --retriesLeft > 0); } /** connection will be null in the case that we couldn't get one on a retry */ if (connection != null) { ReleaseConnection(connection); } LastResult = result; return(result); }
public abstract DBResult Update(DatabaseConnection conn, QueryString sql, OdbcParameterList parms);
public DBResult Insert(QueryString sql) { return(Insert(sql, null)); }
public DBResult Update(QueryString sql) { return(Update(sql, null)); }
public abstract DBResult QueryScalar(DatabaseConnection conn, QueryString sql, out Object result);
public abstract DBResult Query(DatabaseConnection conn, QueryString sql, OdbcParameterList parms, out DatabaseDataReader reader, int timeout = 30);
public abstract DBResult Query(DatabaseConnection conn, QueryString sql, out DatabaseDataReader reader, int timeout = 30);
public virtual DBResult Query(QueryString sql, OdbcParameterList parms, out DatabaseDataReader reader, int timeout = 30) { reader = null; DBResult ret; /** we must be able to get a connection */ DatabaseConnection connection; if ((ret = GetConnection(out connection)).ResultCode == DBResult.Result.Success) { #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.SelectTimer.Start(sql.ToString()); } #endif /** execute the qurey */ ret = Query(connection, sql, parms, out reader, timeout); #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.SelectTimer.Stop(); } #endif if (ret.ResultCode == DBResult.Result.ConnectionDropped) { /** If the connection was lost during the query, we will perform retry logic */ int retriesLeft = connection.ConnectionRetries; do { Log.LogText(LogLevel.WARNING, "The connection was found to be dropped - will retry {0} of {1}", retriesLeft, connection.ConnectionRetries); if (connection != null) { _connectionPool.DropConnection(connection); } if ((ret = GetConnection(out connection)).ResultCode == DBResult.Result.Success) { #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.SelectTimer.Start(sql.ToString()); } #endif ret = Query(connection, sql, out reader); #if INCLUDE_PERFORMANCE_LOGGING if (m_bPerformanceLoggingEnabled) { connection.SelectTimer.Stop(); } #endif } else { /** no connection could be obtained */ connection = null; } if (connection != null && connection.ConnectionRetryInterval != TimeSpan.Zero) { Thread.Sleep(connection.ConnectionRetryInterval); } } while (ret.ResultCode == DBResult.Result.ConnectionDropped && --retriesLeft > 0); if (retriesLeft == 0) { connection = null; } } /** if we successfully got a connection, clean up */ if (connection != null) { /** if we have something to return, create a result set */ if (ret.ResultCode == DBResult.Result.Success) { reader.ConnectionPool = _connectionPool; reader.Connection = connection; } else { ReleaseConnection(connection); reader = new DatabaseDataReader(); } } } LastResult = ret; return(ret); }
public virtual DBResult Query(QueryString sql, out DatabaseDataReader reader, int timeout = 30) { return(Query(sql, null, out reader, timeout)); }