Scrigroup - Documente si articole

Username / Parola inexistente      

Home Documente Upload Resurse Alte limbi doc  


AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows
WordXml

AspAutocadCDot netExcelFox proHtmlJava
LinuxMathcadPhotoshopPhpSqlVisual studioWindowsXml

The DBConnectionSingleton Class

c

+ Font mai mare | - Font mai mic



DOCUMENTE SIMILARE

Trimite pe Messenger
Types, Operators and Expressions: Variable Names
Expressions involving pointers: Conversions, Arithmetic
The DBConnectionSingleton Class
The Task ahead - Logical expressions and Relational Operators
The ReaderWriterLock Class
Pipeline Thread Model
Structures: Basics of Structures
Why Worry About Synchronization
The TraceSwitch Class
Defining Threads - Single-Threaded Processes


The DBConnectionSingleton Class

The DBConnectionSingleton class is the implementation of a database connection-specific object pool. The main purpose of this class is to provide database connection-specific implementations of the Create(), Validate(), and Expire() methods inherited from the ObjectPool class. The class also provides methods called BorrowDBConnection() and ReturnDBConnection() for borrowing and returning database connection objects from the object pool.




The complete listing of the DBConnectionSingleton class is as follows:

using System;
using System.Data.SqlClient;

namespace WroxCS


public static readonly DBConnectionSingleton Instance =
new DBConnectionSingleton();

private static string _connectionString =
@'server=(local);Trusted Connection=yes;database=northwind';

public static string ConnectionString

get



protected override object Create()


protected override bool Validate(object o)

catch (SqlException)



protected override void Expire(object o)

catch (SqlException)



public SqlConnection BorrowDBConnection()

catch (Exception e)


public void ReturnDBConnection(SqlConnection c)



As you are dealing with the SqlConnection object, the Expire() method closes the SqlConnection, the Create() method creates the SqlConnection, and the Validate() method checks whether the SqlConnection is open or not. The whole synchronization issue is hidden from the client application using the DBConnectionSingleton object instance.








Politica de confidentialitate



DISTRIBUIE DOCUMENTUL

Comentarii


Vizualizari: 429
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2021 . All rights reserved

Distribuie URL

Adauga cod HTML in site