当前位置:首页 > 开发教程 > mysql教程 >

MySQL Connection String Samples(2)

时间:2013-04-24 22:49 来源:网络整理 作者:采集侠 收藏

Server = myServerAddress ; Database = myDataBase ; Uid = myUsername ; Pwd = myPassword ; ConvertZeroDateTime = True ; Returns System.DateTime.MinValue valued System.DateTime object for invalid values

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
ConvertZeroDateTime=True;

Returns System.DateTime.MinValue valued System.DateTime object for invalid values and a System.DateTime object for valid values.

 

 

Disable transaction participation

The use of auto enlist transactionscope (default behaviour) could cause trouble in medium trust environments.

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
AutoEnlist=False;

 

 

Skip parameter checks for stored routines

Default behaviour is that parameters for stored routines (stored procedures) are checked against the server

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
CheckParameters=False;

Some permissions and value casting related errors reported fixed when using this connection option.

 

 

Skip parameter type and order matching for stored procedures

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
UseProcedureBodies=False;

The default behaviour is to read tables mysql.proc/INFORMATION_SCHEMA.ROUTINES and try to map provided command parameter values to the called procedures parameters and type cast values accordingly.

This can be troublesome if permissions to the (aforementioned) sproc info tables are insufficient.

The driver will not automatically map the parameters so you must manually set parameter types and you must also make sure to add the parameters to the command object in the exact order as appeared in the procedure definition.

This option is available from Connector/NET version 5.0.4

 

 

Use Table Caching

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
tablecache=true;DefaultTableCacheAge=30;

Specifying DefaultTableCacheAge is optional, default value is 60 seconds.

This option is available from Connector/NET version 6.4

 

 

Count changed rows instead of found rows

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
UseAffectedRows=True;

This option is available from Connector/NET version 5.2.6

 

 

Compress network communication between client and server

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
UseCompression=True;

 

 

Log inefficient database operations

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
UseUsageAdvisor=True;

 

 

Enable performance counters

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
UsePerformanceMonitor=True;

 

 

Connection Pooling

From version 6.2 idle connections are removed from the pool, freeing resources on the client (sockets) and the server (sockets and threads). Do not manually keep (global) connections and open close. Keep connection object creation and disposal as tight as possible, this might be counterintuitive but pooling mechanisms will take care of caching well and your code will be cleaner.

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Pooling=True;

This is the default behaviour.

 

 

Connection Pool size

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
MinimumPoolSize=10;maximumpoolsize=50;

Default values are 0 and 100.

 

 

Disable connection pooling

mysql教程阅读排行

最新文章