1.1

Table Of Contents
For example:
string sqlfHost = "localhost";
int sqlfPort = 1527;
string connectionStr = string.Format(@"server={0}:{1}", sqlfHost, sqlfPort);
SQLFClientConnection connection = null;
try
{
// Initialize and open connection
connection = new SQLFClientConnection(connectionStr);
connection.Open();
///
/// Execute SQLFire commands
///
}
catch (Exception e)
{
///
/// Log or re-throw exception
///
}
finally
{
connection.Close();
}
This creates a client connection to a SQLFire server running on the local machine and listening on the default
port 1527. After you obtain a connection you can execute DDL and DML statements as necessary.
Managing Connections
In this release of SQLFire, the VMWare.Data.SQLFire.SQLFClientConnection class and underlying driver do
not maintain any implicit pool of connections. Creating a new client connection to a SQLFire cluster is a somewhat
expensive operation, so use connection resources carefully.
There are two possible approaches for managing connections:
Use a custom pool of connections. The pool can be maintained as a thread-safe bounded queue of available
connections. When a module is done with the connection, it can return the connection to the queue. If many
connections are lying idle in the pool for some time, those connections can be cleaned up. This approach
requires some work to implement, but tuning a connection pool for application requirements generally provides
the best performance and resource utilization.
Use a thread-local connection. This approach relies on having a connection in the thread local (ThreadStatic
attribute), so that all modules can access the connection quickly without having to create it explicitly. The
advantage of this approach is that applications do not need to pass the connection object to all of the modules
that require access. Each module can obtain the ThreadStatic connection when required. Although this approach
is easier to implement, it is useful only in scenarios where an application has a xed set of threads, or long-lived
threads that operate against a SQLFire system.
Executing SQL Commands
To execute a SQL command, create a SQLFCommand from the SQLFire connection and supply the text of a
SQL command.
For example:
string sqlfHost = "localhost";
int sqlfPort = 1527;
vFabric SQLFire User's Guide130
Developing Applications with SQLFire