ConnectionManager
Overview
Includes the functionality required to handle a list of database connection definitions, instantiate actual connections and determine pooling settings.
The list of connections known to your server is loaded by using one of the several Load methods of this class (by default the parameter-less one) at startup. Once the list is loaded, you can then create a new connection or acquire them from pools by using the AcquireConnection method. Once you're done using the connection, you will need to return it to the connection manager through the use of the ReleaseConnection method.
The PoolingEnabled property determines if you want Data Abstract to use its own pooling mechanism rather than relying on ADO.NET's (which might or might not be available in some ADO.NET data providers). For additional pooling options, look at the PoolingBehavior, PoolTimeoutSeconds, WaitIntervalSeconds and MaxPoolSize properties.
Location
- Reference: RemObjects.DataAbstract.Server.dll
- Namespace: RemObjects.DataAbstract.Server
- Ancestry: BaseComponent | SerializableComponent | ConnectionManager
constructor
constructor
ConnectionManager()
Sub New()
constructor (IContainer)
constructor(container: IContainer)
ConnectionManager(IContainer container)
Sub New(container As IContainer)
Parameters:
- container:
constructor (Boolean)
constructor(register: Boolean)
ConnectionManager(Boolean register)
Sub New(register As Boolean)
Parameters:
- register:
AcquireConnection
method AcquireConnection: IAbstractConnection
IAbstractConnection AcquireConnection()
Function AcquireConnection() As IAbstractConnection
AcquireConnection (Boolean): IAbstractConnection
method AcquireConnection(connect: Boolean): IAbstractConnection
IAbstractConnection AcquireConnection(Boolean connect)
Function AcquireConnection(connect As Boolean) As IAbstractConnection
Parameters:
- connect:
AcquireConnection (String): IAbstractConnection
method AcquireConnection(name: String): IAbstractConnection
IAbstractConnection AcquireConnection(String name)
Function AcquireConnection(name As String) As IAbstractConnection
Parameters:
- name:
AcquireConnection (String, Boolean): IAbstractConnection
Returns a connection whose connection string is the same as the connection definition with the given name. The Boolean parameter determines if you want the connection to be opened automatically or not.
method AcquireConnection(name: String; connect: Boolean): IAbstractConnection
IAbstractConnection AcquireConnection(String name, Boolean connect)
Function AcquireConnection(name As String, connect As Boolean) As IAbstractConnection
Parameters:
- name:
- connect:
AcquireNewConnection
method AcquireNewConnection(connectionString: String; connect: Boolean): IAbstractConnection
IAbstractConnection AcquireNewConnection(String connectionString, Boolean connect)
Function AcquireNewConnection(connectionString As String, connect As Boolean) As IAbstractConnection
Parameters:
- connectionString:
- connect:
AddDefinition (String, String): ConnectionDefinition
method AddDefinition(name: String; connectionString: String): ConnectionDefinition
ConnectionDefinition AddDefinition(String name, String connectionString)
Function AddDefinition(name As String, connectionString As String) As ConnectionDefinition
Parameters:
- name:
- connectionString:
AddDefinition (String, String, Boolean): ConnectionDefinition
Adds a connection definition to the ConnectionDefinitions collection. Makes the similar action as ConnectionDefinitions.Add.
method AddDefinition(name: String; connectionString: String; isDefault: Boolean): ConnectionDefinition
ConnectionDefinition AddDefinition(String name, String connectionString, Boolean isDefault)
Function AddDefinition(name As String, connectionString As String, isDefault As Boolean) As ConnectionDefinition
Parameters:
- name:
- connectionString:
- isDefault:
ClearPool
method ClearPool
void ClearPool()
Sub ClearPool()
ConnectionAcquired
Occurs whenever a connection is returned by the AcquireConnection method. Note: This event occurs whether or not the connection is held in a pool.
event ConnectionAcquired: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionAcquired()
Event ConnectionAcquired As EventHandler<ConnectionNotificationEventArgs>
ConnectionCreated
Occurs whenever a new connection is created during a call to AcquireConnection. Note: This event only occurs if connection manager pooling is not enabled.
event ConnectionCreated: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionCreated()
Event ConnectionCreated As EventHandler<ConnectionNotificationEventArgs>
ConnectionDefinitions
Provides access to the list of connection definitions held by the connection manager.
property ConnectionDefinitions: ConnectionDefinitionCollection read;
ConnectionDefinitionCollection ConnectionDefinitions { get; }
ReadOnly Property ConnectionDefinitions() As ConnectionDefinitionCollection
ConnectionFailed
event ConnectionFailed: EventHandler<ConnectionFailedEventArgs>;
delegate EventHandler<ConnectionFailedEventArgs> ConnectionFailed()
Event ConnectionFailed As EventHandler<ConnectionFailedEventArgs>
ConnectionPoolTimeout
property ConnectionPoolTimeout: Int32 read write;
Int32 ConnectionPoolTimeout { get; set; }
Property ConnectionPoolTimeout() As Int32
ConnectionReleased
Occurs anytime a connection is released through the use of the ReleaseConnection method.
event ConnectionReleased: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionReleased()
Event ConnectionReleased As EventHandler<ConnectionNotificationEventArgs>
CustomPoolTransactionBehavior
event CustomPoolTransactionBehavior: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> CustomPoolTransactionBehavior()
Event CustomPoolTransactionBehavior As EventHandler<ConnectionNotificationEventArgs>
DefaultConnectionDefinition
Returns the connection definition, whose Default property is set to true, from the list referenced by the property ConnectionDefinitions.
property DefaultConnectionDefinition: ConnectionDefinition read;
ConnectionDefinition DefaultConnectionDefinition { get; }
ReadOnly Property DefaultConnectionDefinition() As ConnectionDefinition
DefaultConnectionName
Returns the name of the connection returned by DefaultConnectionDefinition or an empty string if that property returns null.
property DefaultConnectionName: String read;
String DefaultConnectionName { get; }
ReadOnly Property DefaultConnectionName() As String
Dispose protected
method Dispose(disposing: Boolean)
void Dispose(Boolean disposing)
Sub Dispose(disposing As Boolean)
Parameters:
- disposing:
EnableAdoConnectionPooling
property EnableAdoConnectionPooling: Boolean read write;
Boolean EnableAdoConnectionPooling { get; set; }
Property EnableAdoConnectionPooling() As Boolean
FileFormat (declared in SerializableComponent)
property FileFormat: SerializableFormat read write;
SerializableFormat FileFormat { get; set; }
Property FileFormat() As SerializableFormat
Load
Loads a Data Abstract connections file using the default mechanism, which looks in several places for a valid .daConnections file:
- as a <ApplicationName>.daConnnections file next to your application's executable
- as a <ApplicationName>.daConnnections resource in your application's executable
If your application does not provide a custom DataAbstract.daConfig, either as file or as embedded resource, the call will fail with an exception.
method Load
void Load()
Sub Load()
LoadFromFile
method LoadFromFile
void LoadFromFile()
Sub LoadFromFile()
LoadFromFile (String)
Loads a Data Abstract connection from the specified file. If the filename is empty, the configuration will be loaded from a <ApplicationName>.daConnctions file next to your application's executable.
method LoadFromFile(filename: String)
void LoadFromFile(String filename)
Sub LoadFromFile(filename As String)
Parameters:
- filename:
LoadFromJson (declared in SerializableComponent)
method LoadFromJson(json: String)
void LoadFromJson(String json)
Sub LoadFromJson(json As String)
Parameters:
- json:
LoadFromResource (String)
Loads a Data Abstract connection from a resource in your application's executable. If the resource name is empty, the connections will be loaded from a resource named <ApplicationName>.daConnctions.
method LoadFromResource(resourceName: String)
void LoadFromResource(String resourceName)
Sub LoadFromResource(resourceName As String)
Parameters:
- resourceName:
LoadFromResource (String, Assembly)
method LoadFromResource(resourceName: String; assembly: Assembly)
void LoadFromResource(String resourceName, Assembly assembly)
Sub LoadFromResource(resourceName As String, assembly As Assembly)
Parameters:
- resourceName:
- assembly:
LoadFromStream (declared in SerializableComponent)
method LoadFromStream(stream: Stream)
void LoadFromStream(Stream stream)
Sub LoadFromStream(stream As Stream)
Parameters:
- stream:
LoadFromString (declared in SerializableComponent)
method LoadFromString(aString: String)
void LoadFromString(String aString)
Sub LoadFromString(aString As String)
Parameters:
- aString:
LoadFromXml (XmlDocument)
Loads a Data Abstract connections from an IXMLDocument. Use this method if you want to obtain the list of connections by other means then from a local file or a resource.
method LoadFromXml(xml: XmlDocument)
void LoadFromXml(XmlDocument xml)
Sub LoadFromXml(xml As XmlDocument)
Parameters:
- xml:
LoadFromXml (XmlNode) (declared in SerializableComponent)
method LoadFromXml(xml: XmlNode)
void LoadFromXml(XmlNode xml)
Sub LoadFromXml(xml As XmlNode)
Parameters:
- xml:
MaxPoolSize
Defines the maximum number of connections that connection pools can hold.
property MaxPoolSize: Int32 read write;
Int32 MaxPoolSize { get; set; }
Property MaxPoolSize() As Int32
PoolingBehavior
Determines how the connection pool behaves if no connections are available to serve a call to AcquireConnection. Depending on the assigned value, AcquireConnection will either wait until a connection becomes available, return an error, or create a new unpooled connection.
property PoolingBehavior: PoolBehavior read write;
PoolBehavior PoolingBehavior { get; set; }
Property PoolingBehavior() As PoolBehavior
PoolingEnabled
Determines if Data Abstract connection pooling should be enabled or not.
property PoolingEnabled: Boolean read write;
Boolean PoolingEnabled { get; set; }
Property PoolingEnabled() As Boolean
PoolTimeoutSeconds
property PoolTimeoutSeconds: Int32 read write;
Int32 PoolTimeoutSeconds { get; set; }
Property PoolTimeoutSeconds() As Int32
PoolTransactionBehaviour
property PoolTransactionBehaviour: PoolTransactionBehaviour read write;
PoolTransactionBehaviour PoolTransactionBehaviour { get; set; }
Property PoolTransactionBehaviour() As PoolTransactionBehaviour
ReleaseConnection (IAbstractConnection)
method ReleaseConnection(connection: IAbstractConnection)
void ReleaseConnection(IAbstractConnection connection)
Sub ReleaseConnection(connection As IAbstractConnection)
Parameters:
- connection:
ReleaseConnection (IAbstractConnection, Boolean)
Releases a connection previously acquired using the AcquireConnection method. If the connection originally belonged to a pool, it is returned to it. In either case, the variable referenced by method's parameter is set to null.
method ReleaseConnection(connection: IAbstractConnection; keepInPool: Boolean)
void ReleaseConnection(IAbstractConnection connection, Boolean keepInPool)
Sub ReleaseConnection(connection As IAbstractConnection, keepInPool As Boolean)
Parameters:
- connection:
- keepInPool:
SaveToFile (declared in SerializableComponent)
method SaveToFile(filename: String)
void SaveToFile(String filename)
Sub SaveToFile(filename As String)
Parameters:
- filename:
SaveToJson (declared in SerializableComponent)
method SaveToJson: String
String SaveToJson()
Function SaveToJson() As String
SaveToStream (declared in SerializableComponent)
method SaveToStream(stream: Stream)
void SaveToStream(Stream stream)
Sub SaveToStream(stream As Stream)
Parameters:
- stream:
SaveToString (declared in SerializableComponent)
method SaveToString: String
String SaveToString()
Function SaveToString() As String
SaveToXml (declared in SerializableComponent)
method SaveToXml(xml: XmlNode)
void SaveToXml(XmlNode xml)
Sub SaveToXml(xml As XmlNode)
Parameters:
- xml:
WaitIntervalSeconds
Determines how many seconds to wait for a connection to be released from a pool before timing out.
property WaitIntervalSeconds: Int32 read write;
Int32 WaitIntervalSeconds { get; set; }
Property WaitIntervalSeconds() As Int32
ConnectionDefinitions
Provides access to the list of connection definitions held by the connection manager.
property ConnectionDefinitions: ConnectionDefinitionCollection read;
ConnectionDefinitionCollection ConnectionDefinitions { get; }
ReadOnly Property ConnectionDefinitions() As ConnectionDefinitionCollection
ConnectionPoolTimeout
property ConnectionPoolTimeout: Int32 read write;
Int32 ConnectionPoolTimeout { get; set; }
Property ConnectionPoolTimeout() As Int32
DefaultConnectionDefinition
Returns the connection definition, whose Default property is set to true, from the list referenced by the property ConnectionDefinitions.
property DefaultConnectionDefinition: ConnectionDefinition read;
ConnectionDefinition DefaultConnectionDefinition { get; }
ReadOnly Property DefaultConnectionDefinition() As ConnectionDefinition
DefaultConnectionName
Returns the name of the connection returned by DefaultConnectionDefinition or an empty string if that property returns null.
property DefaultConnectionName: String read;
String DefaultConnectionName { get; }
ReadOnly Property DefaultConnectionName() As String
EnableAdoConnectionPooling
property EnableAdoConnectionPooling: Boolean read write;
Boolean EnableAdoConnectionPooling { get; set; }
Property EnableAdoConnectionPooling() As Boolean
FileFormat (declared in SerializableComponent)
property FileFormat: SerializableFormat read write;
SerializableFormat FileFormat { get; set; }
Property FileFormat() As SerializableFormat
MaxPoolSize
Defines the maximum number of connections that connection pools can hold.
property MaxPoolSize: Int32 read write;
Int32 MaxPoolSize { get; set; }
Property MaxPoolSize() As Int32
PoolingBehavior
Determines how the connection pool behaves if no connections are available to serve a call to AcquireConnection. Depending on the assigned value, AcquireConnection will either wait until a connection becomes available, return an error, or create a new unpooled connection.
property PoolingBehavior: PoolBehavior read write;
PoolBehavior PoolingBehavior { get; set; }
Property PoolingBehavior() As PoolBehavior
PoolingEnabled
Determines if Data Abstract connection pooling should be enabled or not.
property PoolingEnabled: Boolean read write;
Boolean PoolingEnabled { get; set; }
Property PoolingEnabled() As Boolean
PoolTimeoutSeconds
property PoolTimeoutSeconds: Int32 read write;
Int32 PoolTimeoutSeconds { get; set; }
Property PoolTimeoutSeconds() As Int32
PoolTransactionBehaviour
property PoolTransactionBehaviour: PoolTransactionBehaviour read write;
PoolTransactionBehaviour PoolTransactionBehaviour { get; set; }
Property PoolTransactionBehaviour() As PoolTransactionBehaviour
WaitIntervalSeconds
Determines how many seconds to wait for a connection to be released from a pool before timing out.
property WaitIntervalSeconds: Int32 read write;
Int32 WaitIntervalSeconds { get; set; }
Property WaitIntervalSeconds() As Int32
constructor
constructor
ConnectionManager()
Sub New()
constructor (IContainer)
constructor(container: IContainer)
ConnectionManager(IContainer container)
Sub New(container As IContainer)
Parameters:
- container:
constructor (Boolean)
constructor(register: Boolean)
ConnectionManager(Boolean register)
Sub New(register As Boolean)
Parameters:
- register:
AcquireConnection
method AcquireConnection: IAbstractConnection
IAbstractConnection AcquireConnection()
Function AcquireConnection() As IAbstractConnection
AcquireConnection (Boolean): IAbstractConnection
method AcquireConnection(connect: Boolean): IAbstractConnection
IAbstractConnection AcquireConnection(Boolean connect)
Function AcquireConnection(connect As Boolean) As IAbstractConnection
Parameters:
- connect:
AcquireConnection (String): IAbstractConnection
method AcquireConnection(name: String): IAbstractConnection
IAbstractConnection AcquireConnection(String name)
Function AcquireConnection(name As String) As IAbstractConnection
Parameters:
- name:
AcquireConnection (String, Boolean): IAbstractConnection
Returns a connection whose connection string is the same as the connection definition with the given name. The Boolean parameter determines if you want the connection to be opened automatically or not.
method AcquireConnection(name: String; connect: Boolean): IAbstractConnection
IAbstractConnection AcquireConnection(String name, Boolean connect)
Function AcquireConnection(name As String, connect As Boolean) As IAbstractConnection
Parameters:
- name:
- connect:
AcquireNewConnection
method AcquireNewConnection(connectionString: String; connect: Boolean): IAbstractConnection
IAbstractConnection AcquireNewConnection(String connectionString, Boolean connect)
Function AcquireNewConnection(connectionString As String, connect As Boolean) As IAbstractConnection
Parameters:
- connectionString:
- connect:
AddDefinition (String, String): ConnectionDefinition
method AddDefinition(name: String; connectionString: String): ConnectionDefinition
ConnectionDefinition AddDefinition(String name, String connectionString)
Function AddDefinition(name As String, connectionString As String) As ConnectionDefinition
Parameters:
- name:
- connectionString:
AddDefinition (String, String, Boolean): ConnectionDefinition
Adds a connection definition to the ConnectionDefinitions collection. Makes the similar action as ConnectionDefinitions.Add.
method AddDefinition(name: String; connectionString: String; isDefault: Boolean): ConnectionDefinition
ConnectionDefinition AddDefinition(String name, String connectionString, Boolean isDefault)
Function AddDefinition(name As String, connectionString As String, isDefault As Boolean) As ConnectionDefinition
Parameters:
- name:
- connectionString:
- isDefault:
ClearPool
method ClearPool
void ClearPool()
Sub ClearPool()
Dispose protected
method Dispose(disposing: Boolean)
void Dispose(Boolean disposing)
Sub Dispose(disposing As Boolean)
Parameters:
- disposing:
Load
Loads a Data Abstract connections file using the default mechanism, which looks in several places for a valid .daConnections file:
- as a <ApplicationName>.daConnnections file next to your application's executable
- as a <ApplicationName>.daConnnections resource in your application's executable
If your application does not provide a custom DataAbstract.daConfig, either as file or as embedded resource, the call will fail with an exception.
method Load
void Load()
Sub Load()
LoadFromFile
method LoadFromFile
void LoadFromFile()
Sub LoadFromFile()
LoadFromFile (String)
Loads a Data Abstract connection from the specified file. If the filename is empty, the configuration will be loaded from a <ApplicationName>.daConnctions file next to your application's executable.
method LoadFromFile(filename: String)
void LoadFromFile(String filename)
Sub LoadFromFile(filename As String)
Parameters:
- filename:
LoadFromJson (declared in SerializableComponent)
method LoadFromJson(json: String)
void LoadFromJson(String json)
Sub LoadFromJson(json As String)
Parameters:
- json:
LoadFromResource (String)
Loads a Data Abstract connection from a resource in your application's executable. If the resource name is empty, the connections will be loaded from a resource named <ApplicationName>.daConnctions.
method LoadFromResource(resourceName: String)
void LoadFromResource(String resourceName)
Sub LoadFromResource(resourceName As String)
Parameters:
- resourceName:
LoadFromResource (String, Assembly)
method LoadFromResource(resourceName: String; assembly: Assembly)
void LoadFromResource(String resourceName, Assembly assembly)
Sub LoadFromResource(resourceName As String, assembly As Assembly)
Parameters:
- resourceName:
- assembly:
LoadFromStream (declared in SerializableComponent)
method LoadFromStream(stream: Stream)
void LoadFromStream(Stream stream)
Sub LoadFromStream(stream As Stream)
Parameters:
- stream:
LoadFromString (declared in SerializableComponent)
method LoadFromString(aString: String)
void LoadFromString(String aString)
Sub LoadFromString(aString As String)
Parameters:
- aString:
LoadFromXml (XmlDocument)
Loads a Data Abstract connections from an IXMLDocument. Use this method if you want to obtain the list of connections by other means then from a local file or a resource.
method LoadFromXml(xml: XmlDocument)
void LoadFromXml(XmlDocument xml)
Sub LoadFromXml(xml As XmlDocument)
Parameters:
- xml:
LoadFromXml (XmlNode) (declared in SerializableComponent)
method LoadFromXml(xml: XmlNode)
void LoadFromXml(XmlNode xml)
Sub LoadFromXml(xml As XmlNode)
Parameters:
- xml:
ReleaseConnection (IAbstractConnection)
method ReleaseConnection(connection: IAbstractConnection)
void ReleaseConnection(IAbstractConnection connection)
Sub ReleaseConnection(connection As IAbstractConnection)
Parameters:
- connection:
ReleaseConnection (IAbstractConnection, Boolean)
Releases a connection previously acquired using the AcquireConnection method. If the connection originally belonged to a pool, it is returned to it. In either case, the variable referenced by method's parameter is set to null.
method ReleaseConnection(connection: IAbstractConnection; keepInPool: Boolean)
void ReleaseConnection(IAbstractConnection connection, Boolean keepInPool)
Sub ReleaseConnection(connection As IAbstractConnection, keepInPool As Boolean)
Parameters:
- connection:
- keepInPool:
SaveToFile (declared in SerializableComponent)
method SaveToFile(filename: String)
void SaveToFile(String filename)
Sub SaveToFile(filename As String)
Parameters:
- filename:
SaveToJson (declared in SerializableComponent)
method SaveToJson: String
String SaveToJson()
Function SaveToJson() As String
SaveToStream (declared in SerializableComponent)
method SaveToStream(stream: Stream)
void SaveToStream(Stream stream)
Sub SaveToStream(stream As Stream)
Parameters:
- stream:
SaveToString (declared in SerializableComponent)
method SaveToString: String
String SaveToString()
Function SaveToString() As String
SaveToXml (declared in SerializableComponent)
method SaveToXml(xml: XmlNode)
void SaveToXml(XmlNode xml)
Sub SaveToXml(xml As XmlNode)
Parameters:
- xml:
ConnectionAcquired
Occurs whenever a connection is returned by the AcquireConnection method. Note: This event occurs whether or not the connection is held in a pool.
event ConnectionAcquired: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionAcquired()
Event ConnectionAcquired As EventHandler<ConnectionNotificationEventArgs>
ConnectionCreated
Occurs whenever a new connection is created during a call to AcquireConnection. Note: This event only occurs if connection manager pooling is not enabled.
event ConnectionCreated: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionCreated()
Event ConnectionCreated As EventHandler<ConnectionNotificationEventArgs>
ConnectionFailed
event ConnectionFailed: EventHandler<ConnectionFailedEventArgs>;
delegate EventHandler<ConnectionFailedEventArgs> ConnectionFailed()
Event ConnectionFailed As EventHandler<ConnectionFailedEventArgs>
ConnectionReleased
Occurs anytime a connection is released through the use of the ReleaseConnection method.
event ConnectionReleased: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> ConnectionReleased()
Event ConnectionReleased As EventHandler<ConnectionNotificationEventArgs>
CustomPoolTransactionBehavior
event CustomPoolTransactionBehavior: EventHandler<ConnectionNotificationEventArgs>;
delegate EventHandler<ConnectionNotificationEventArgs> CustomPoolTransactionBehavior()
Event CustomPoolTransactionBehavior As EventHandler<ConnectionNotificationEventArgs>