Oracle 5.0 Reference Manual page 1922

Table of Contents

Advertisement

specified. The
following code snippet:
...
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "mytable";
cmd.Connection = someConnection;
cmd.CommandType = CommandType.TableDirect;
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLn(reader[0], reader[1]...);
}
...
Examples of using the CommandType of StoredProcedure can be found in the section
Section 20.2.5.9, "Accessing Stored Procedures with
Commands can have a timeout associated with them. This is useful as you may not want a
situation were a command takes up an excessive amount of time. A timeout can be set using the
CommandTimeout
MySqlCommand cmd = new MySqlCommand();
cmd.CommandTimeout = 60;
The default value is 30 seconds. Avoid a value of 0, which indicates an indefinite wait. To change the
default command timeout, use the connection string option
Prior to MySQL Connector/Net 6.2,
time, that is processing time not related to direct use of the connector. Timeout was implemented
through a .NET Timer, that triggered after
MySQL Connector/Net 6.2 introduced timeouts that are aligned with how Microsoft handles
SqlCommand.CommandTimeout. This property is the cumulative timeout for all network reads
and writes during command execution or processing of the results. A timeout can still occur in the
MySqlReader.Read
time, only IO operations. The 6.2 implementation uses the underlying stream timeout facility, so is
more efficient in that it does not require the additional timer thread as was the case with the previous
implementation.
Further details on this can be found in the relevant
20.2.5.4. Using Connector/Net with Connection Pooling
The Connector/Net supports connection pooling for better performance and scalability with database-
intensive applications. This is enabled by default. You can turn it off or adjust its performance
characteristics using the connection string options Pooling,
Lifetime,
Section 20.2.5.2, "Creating a Connector/Net Connection String"
Connection pooling works by keeping the native connection to the server live when the client disposes
of a MySqlConnection. Subsequently, if a new
created from the connection pool, rather than creating a new native connection. This improves
performance.
Guidelines
To work as designed, it is best to let the connection pooling system manage all connections. Do not
create a globally accessible instance of
interferes with the way the pooling works and can lead to unpredictable results or even exceptions.
One approach that simplifies things is to avoid manually creating a
use the overloaded methods that take a connection string as an argument. Using this approach,
Connector/Net Programming
property is set to the name of the table to query. This is illustrated by the
CommandText
property. The following code snippet sets a timeout of one minute:
method after the first row is returned, and does not include user processing
Cache Server
Properties,
Connector/Net".
MySqlCommand.CommandTimeout
CommandTimeout
Microsoft
Max Pool Size
MySqlConnection
MySqlConnection
1902
Default Command
Timeout.
included user processing
seconds. This timer consumed a thread.
documentation.
Connection
Reset,
and
Size. See
Min Pool
for further information.
object is opened, it will be
and then manually open and close it. This
MySqlConnection
Connection
object. Instead

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents