Pool Connection UniDirect
Posted: Thu 14 Feb 2008 10:28
Hello everyone,
I have some questions with pool connection in UniDirect .NET.
I am a software engineer of Spain, and my company buy UniDirect Component recently.
I use it for connect _Oracle and SQLServer databases, and I can't understand how to use the pool connection.
In documents, I can read how to active the pool (in connection string, specifing Max Pool, Min Pool, Connection LifeTime,...). But, I tested using threads, and, in the second thread execution, produces an Exception ("type Internal Connection fatal"). I don't know the why of this.
Another questions, I wanted to know the number of active connection in one specific moment. How can I do this?
I paste the code of test program in c#:
using System;
using System.Text;
using System.Threading;
using CoreLab.UniDirect;
namespace BBDDPool_SQL
{
class Program
{
public static UniConnection vConnectionString;
static Thread thOpen1, thOpen2;
static void Main(string[] args)
{
try
{
//create connection
vConnectionString=new UniConnection("Provider=SQL
Server;server=...;initial catalog=...;user
id=...;password=...;Pooling=true;Max Pool Size=4;Min Pool
Size=1;Connection Lifetime=130;");
//open first connection
vConnectionString.Open();
Console.WriteLine("open connection");
//create and run threads
thOpen1 = new Thread(new ThreadStart(OpenConnection));
thOpen2 = new Thread(new ThreadStart(OpenConnection));
thOpen1.Start();
thOpen2.Start();
Console.ReadLine();
}
catch (Exception ex)
{
}
}
public static void OpenConnection()
{
try
{
vConnectionString.Open();
UniCommand oCommand =
vConnectionString.CreateCommand();
oCommand.CommandText = "select * from ...";
UniDataReader oRecordset = oCommand.ExecuteReader();
Console.WriteLine("open connection");
}
catch (Exception ex)
{
}
}
}
}
Thanks a lot.
ERIK.
I have some questions with pool connection in UniDirect .NET.
I am a software engineer of Spain, and my company buy UniDirect Component recently.
I use it for connect _Oracle and SQLServer databases, and I can't understand how to use the pool connection.
In documents, I can read how to active the pool (in connection string, specifing Max Pool, Min Pool, Connection LifeTime,...). But, I tested using threads, and, in the second thread execution, produces an Exception ("type Internal Connection fatal"). I don't know the why of this.
Another questions, I wanted to know the number of active connection in one specific moment. How can I do this?
I paste the code of test program in c#:
using System;
using System.Text;
using System.Threading;
using CoreLab.UniDirect;
namespace BBDDPool_SQL
{
class Program
{
public static UniConnection vConnectionString;
static Thread thOpen1, thOpen2;
static void Main(string[] args)
{
try
{
//create connection
vConnectionString=new UniConnection("Provider=SQL
Server;server=...;initial catalog=...;user
id=...;password=...;Pooling=true;Max Pool Size=4;Min Pool
Size=1;Connection Lifetime=130;");
//open first connection
vConnectionString.Open();
Console.WriteLine("open connection");
//create and run threads
thOpen1 = new Thread(new ThreadStart(OpenConnection));
thOpen2 = new Thread(new ThreadStart(OpenConnection));
thOpen1.Start();
thOpen2.Start();
Console.ReadLine();
}
catch (Exception ex)
{
}
}
public static void OpenConnection()
{
try
{
vConnectionString.Open();
UniCommand oCommand =
vConnectionString.CreateCommand();
oCommand.CommandText = "select * from ...";
UniDataReader oRecordset = oCommand.ExecuteReader();
Console.WriteLine("open connection");
}
catch (Exception ex)
{
}
}
}
}
Thanks a lot.
ERIK.