本文整理汇总了C#中ServerStatusFlags类的典型用法代码示例。如果您正苦于以下问题:C# ServerStatusFlags类的具体用法?C# ServerStatusFlags怎么用?C# ServerStatusFlags使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerStatusFlags类属于命名空间,在下文中一共展示了ServerStatusFlags类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckEOF
private void CheckEOF()
{
if (!packet.IsLastPacket)
throw new MySqlException("Expected end of data packet");
packet.ReadByte(); // read off the 254
if (packet.HasMoreData)
{
warnings += packet.ReadInteger(2);
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
// if we are at the end of this cursor based resultset, then we remove
// the last row sent status flag so our next fetch doesn't abort early
// and we remove this command result from our list of active CommandResult objects.
// if ((serverStatus & ServerStatusFlags.LastRowSent) != 0)
// {
// serverStatus &= ~ServerStatusFlags.LastRowSent;
// commandResults.Remove(lastCommandResult);
// }
}
}
示例2: GetResult
public int GetResult(ref int affectedRow, ref long insertedId)
{
try
{
packet = stream.ReadPacket();
}
catch (TimeoutException)
{
// Do not reset serverStatus, allow to reenter, e.g when
// ResultSet is closed.
throw;
}
catch (Exception)
{
serverStatus = 0;
throw;
}
int fieldCount = (int)packet.ReadFieldLength();
if (-1 == fieldCount)
{
string filename = packet.ReadString();
SendFileToServer(filename);
return GetResult(ref affectedRow, ref insertedId);
}
else if (fieldCount == 0)
{
// the code to read last packet will set these server status vars
// again if necessary.
serverStatus &= ~(ServerStatusFlags.AnotherQuery |
ServerStatusFlags.MoreResults);
affectedRow = (int)packet.ReadFieldLength();
insertedId = (long)packet.ReadFieldLength();
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
warnings += packet.ReadInteger(2);
if (packet.HasMoreData)
{
packet.ReadLenString(); //TODO: server message
}
}
return fieldCount;
}
示例3: ExecuteStatement
public void ExecuteStatement(MySqlPacket packetToExecute)
{
warnings = 0;
packetToExecute.Buffer[4] = (byte)DBCmd.EXECUTE;
ExecutePacket(packetToExecute);
serverStatus |= ServerStatusFlags.AnotherQuery;
}
示例4: Open
public void Open()
{
// connect to one of our specified hosts
try
{
#if !CF
if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
{
SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName);
str.Open(Settings.ConnectionTimeout);
baseStream = str;
}
else
{
#endif
string pipeName = Settings.PipeName;
if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
pipeName = null;
StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName,
Settings.Keepalive, this.Version);
#if !CF
if (Settings.IncludeSecurityAsserts)
MySqlSecurityPermission.CreatePermissionSet(false).Assert();
#endif
baseStream = sc.GetStream(Settings.ConnectionTimeout);
#if !CF
}
#endif
}
catch (System.Security.SecurityException)
{
throw;
}
catch (Exception ex)
{
throw new MySqlException(Resources.UnableToConnectToHost,
(int)MySqlErrorCode.UnableToConnectToHost, ex);
}
if (baseStream == null)
throw new MySqlException(Resources.UnableToConnectToHost,
(int)MySqlErrorCode.UnableToConnectToHost);
int maxSinglePacket = 255 * 255 * 255;
stream = new MySqlStream(baseStream, Encoding, false);
stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);
// read off the welcome packet and parse out it's values
packet = stream.ReadPacket();
int protocol = packet.ReadByte();
string versionString = packet.ReadString();
version = DBVersion.Parse(versionString);
if (!version.isAtLeast(5, 0, 0))
throw new NotSupportedException(Resources.ServerTooOld);
threadId = packet.ReadInteger(4);
encryptionSeed = packet.ReadString();
maxSinglePacket = (256 * 256 * 256) - 1;
// read in Server capabilities if they are provided
ClientFlags serverCaps = 0;
if (packet.HasMoreData)
serverCaps = (ClientFlags)packet.ReadInteger(2);
/* New protocol with 16 bytes to describe server characteristics */
owner.ConnectionCharSetIndex = (int)packet.ReadByte();
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
// Since 5.5, high bits of server caps are stored after status.
// Previously, it was part of reserved always 0x00 13-byte filler.
uint serverCapsHigh = (uint)packet.ReadInteger(2);
serverCaps |= (ClientFlags)(serverCapsHigh << 16);
packet.Position += 11;
string seedPart2 = packet.ReadString();
encryptionSeed += seedPart2;
string authenticationMethod = "";
if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
{
authenticationMethod = packet.ReadString();
}
else
{
// Some MySql versions like 5.1, don't give name of plugin, default to native password.
authenticationMethod = "mysql_native_password";
}
// based on our settings, set our connection flags
SetConnectionFlags(serverCaps);
packet.Clear();
packet.WriteInteger((int)connectionFlags, 4);
#if !CF
if ((serverCaps & ClientFlags.SSL) == 0)
{
if ((Settings.SslMode != MySqlSslMode.None)
&& (Settings.SslMode != MySqlSslMode.Preferred))
//.........这里部分代码省略.........
示例5: SendQuery
/// <summary>
/// Query is the method that is called to send all queries to the server
/// </summary>
public void SendQuery(MySqlPacket queryPacket)
{
warnings = 0;
queryPacket.Buffer[4] = (byte)DBCmd.QUERY;
ExecutePacket(queryPacket);
// the server will respond in one of several ways with the first byte indicating
// the type of response.
// 0 == ok packet. This indicates non-select queries
// 0xff == error packet. This is handled in stream.OpenPacket
// > 0 = number of columns in select query
// We don't actually read the result here since a single query can generate
// multiple resultsets and we don't want to duplicate code. See ReadResult
// Instead we set our internal server status flag to indicate that we have a query waiting.
// This flag will be maintained by ReadResult
serverStatus |= ServerStatusFlags.AnotherQuery;
}
示例6: ReadOk
internal void ReadOk(bool read)
{
try
{
if (read)
packet = stream.ReadPacket();
byte marker = (byte)packet.ReadByte();
if (marker != 0)
{
throw new MySqlException("Out of sync with server", true, null);
}
packet.ReadFieldLength(); /* affected rows */
packet.ReadFieldLength(); /* last insert id */
if (packet.HasMoreData)
{
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
packet.ReadInteger(2); /* warning count */
if (packet.HasMoreData)
{
packet.ReadLenString(); /* message */
}
}
}
catch (MySqlException ex)
{
HandleException(ex);
throw;
}
}
示例7: HasStatus
public bool HasStatus(ServerStatusFlags flag)
{
return (handler.ServerStatus & flag) != 0;
}
示例8: Open
public void Open()
{
// connect to one of our specified hosts
try
{
baseStream = StreamCreator.GetStream(Settings);
//#if !CF && !RT
// if (Settings.IncludeSecurityAsserts)
// MySqlSecurityPermission.CreatePermissionSet(false).Assert();
//#endif
}
catch (System.Security.SecurityException)
{
throw;
}
catch (Exception ex)
{
throw new MySqlException("Resources.UnableToConnectToHost",
(int)MySqlErrorCode.UnableToConnectToHost, ex);
}
if (baseStream == null)
throw new MySqlException("Resources.UnableToConnectToHost",
(int)MySqlErrorCode.UnableToConnectToHost);
int maxSinglePacket = 255 * 255 * 255;
stream = new MySqlStream(baseStream, Encoding, false);
stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);
// read off the welcome packet and parse out it's values
packet = stream.ReadPacket();
int protocol = packet.ReadByte();
string versionString = packet.ReadString();
owner.isFabric = versionString.EndsWith("fabric", StringComparison.OrdinalIgnoreCase);
version = DBVersion.Parse(versionString);
if (!owner.isFabric && !version.isAtLeast(5, 0, 0))
throw new NotSupportedException("Resources.ServerTooOld");
threadId = packet.ReadInteger(4);
byte[] seedPart1 = packet.ReadStringAsBytes();
maxSinglePacket = (256 * 256 * 256) - 1;
// read in Server capabilities if they are provided
ClientFlags serverCaps = 0;
if (packet.HasMoreData)
serverCaps = (ClientFlags)packet.ReadInteger(2);
/* New protocol with 16 bytes to describe server characteristics */
owner.ConnectionCharSetIndex = (int)packet.ReadByte();
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
// Since 5.5, high bits of server caps are stored after status.
// Previously, it was part of reserved always 0x00 13-byte filler.
uint serverCapsHigh = (uint)packet.ReadInteger(2);
serverCaps |= (ClientFlags)(serverCapsHigh << 16);
packet.Position += 11;
byte[] seedPart2 = packet.ReadStringAsBytes();
encryptionSeed = new byte[seedPart1.Length + seedPart2.Length];
seedPart1.CopyTo(encryptionSeed, 0);
seedPart2.CopyTo(encryptionSeed, seedPart1.Length);
string authenticationMethod = "";
if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
{
authenticationMethod = packet.ReadString();
}
else
{
// Some MySql versions like 5.1, don't give name of plugin, default to native password.
authenticationMethod = "mysql_native_password";
}
// based on our settings, set our connection flags
SetConnectionFlags(serverCaps);
packet.Clear();
packet.WriteInteger((int)connectionFlags, 4);
packet.WriteInteger(maxSinglePacket, 4);
packet.WriteByte(33); //character set utf-8
packet.Write(new byte[23]);
#if !CF && !RT
if ((serverCaps & ClientFlags.SSL) == 0)
{
if ((Settings.SslMode != MySqlSslMode.None)
&& (Settings.SslMode != MySqlSslMode.Preferred))
{
// Client requires SSL connections.
string message = String.Format("Resources.NoServerSSLSupport",
Settings.Server);
throw new MySqlException(message);
}
}
else if (Settings.SslMode != MySqlSslMode.None)
{
//.........这里部分代码省略.........
示例9: Open
public void Open()
{
// connect to one of our specified hosts
baseStream = new RemoteConnection();
baseStream.Connect(MySqlConnection.CurrentStringBuilder.ServerEndPoint, MySqlConnection.CurrentStringBuilder.ServerPort);
int maxSinglePacket = 255 * 255 * 255;
stream = new MySqlStream(baseStream, Encoding, false);
stream.ResetTimeout((int)Settings.ConnectionTimeout * 1000);
// read off the welcome packet and parse out it's values
packet = stream.ReadPacket();
int protocol = packet.ReadByte();
string versionString = packet.ReadString();
version = DBVersion.Parse(versionString);
if (!version.isAtLeast(5, 0, 0))
throw new NotSupportedException(Resources.ServerTooOld);
threadId = packet.ReadInteger(4);
encryptionSeed = packet.ReadString();
maxSinglePacket = (256 * 256 * 256) - 1;
// read in Server capabilities if they are provided
ClientFlags serverCaps = 0;
if (packet.HasMoreData)
serverCaps = (ClientFlags)packet.ReadInteger(2);
/* New protocol with 16 bytes to describe server characteristics */
owner.ConnectionCharSetIndex = (int)packet.ReadByte();
serverStatus = (ServerStatusFlags)packet.ReadInteger(2);
// Since 5.5, high bits of server caps are stored after status.
// Previously, it was part of reserved always 0x00 13-byte filler.
uint serverCapsHigh = (uint)packet.ReadInteger(2);
serverCaps |= (ClientFlags)(serverCapsHigh << 16);
packet.Position += 11;
string seedPart2 = packet.ReadString();
encryptionSeed += seedPart2;
string authenticationMethod = "";
if ((serverCaps & ClientFlags.PLUGIN_AUTH) != 0)
{
authenticationMethod = packet.ReadString();
}
else
{
// Some MySql versions like 5.1, don't give name of plugin, default to native password.
authenticationMethod = "mysql_native_password";
}
// based on our settings, set our connection flags
SetConnectionFlags(serverCaps);
packet.Clear();
packet.WriteInteger((int)connectionFlags, 4);
packet.WriteInteger(maxSinglePacket, 4);
packet.WriteByte(8);
packet.Write(new byte[23]);
Authenticate(authenticationMethod, false);
// if we are using compression, then we use our CompressedStream class
// to hide the ugliness of managing the compression
if ((connectionFlags & ClientFlags.COMPRESS) != 0)
stream = new MySqlStream(baseStream, Encoding, true);
// give our stream the server version we are connected to.
// We may have some fields that are read differently based
// on the version of the server we are connected to.
packet.Version = version;
stream.MaxBlockSize = maxSinglePacket;
}
示例10: Open
public void Open()
{
// connect to one of our specified hosts
try
{
#if !CF
if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
{
SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName);
str.Open(Settings.ConnectionTimeout);
baseStream = str;
}
else
{
#endif
string pipeName = Settings.PipeName;
if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
pipeName = null;
StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName,
Settings.Keepalive);
baseStream = sc.GetStream(Settings.ConnectionTimeout);
#if !CF
}
#endif
}
catch (Exception ex)
{
throw new MySqlException(MySqlResources.UnableToConnectToHost,
(int) MySqlErrorCode.UnableToConnectToHost, ex);
}
if (baseStream == null)
throw new MySqlException(MySqlResources.UnableToConnectToHost,
(int)MySqlErrorCode.UnableToConnectToHost);
int maxSinglePacket = 255*255*255;
stream = new MySqlStream(baseStream, Encoding, false);
stream.ResetTimeout((int)Settings.ConnectionTimeout*1000);
// read off the welcome packet and parse out it's values
packet = stream.ReadPacket();
int protocol = packet.ReadByte();
string versionString = packet.ReadString();
version = DBVersion.Parse(versionString);
if (!version.isAtLeast(4, 1, 1))
throw new NotSupportedException(MySqlResources.ServerTooOld);
threadId = packet.ReadInteger(4);
encryptionSeed = packet.ReadString();
maxSinglePacket = (256*256*256) - 1;
// read in Server capabilities if they are provided
ClientFlags serverCaps = 0;
if (packet.HasMoreData)
serverCaps = (ClientFlags) packet.ReadInteger(2);
/* New protocol with 16 bytes to describe server characteristics */
owner.ConnectionCharSetIndex = (int)packet.ReadByte();
serverStatus = (ServerStatusFlags) packet.ReadInteger(2);
packet.Position += 13;
string seedPart2 = packet.ReadString();
encryptionSeed += seedPart2;
// based on our settings, set our connection flags
SetConnectionFlags(serverCaps);
packet.Clear();
packet.WriteInteger((int) connectionFlags, 4);
#if !CF
if ((serverCaps & ClientFlags.SSL) ==0)
{
if ((Settings.SslMode != MySqlSslMode.None)
&& (Settings.SslMode != MySqlSslMode.Preferred))
{
// Client requires SSL connections.
string message = String.Format(MySqlResources.NoServerSSLSupport,
Settings.Server);
throw new MySqlException(message);
}
}
else if (Settings.SslMode != MySqlSslMode.None)
{
stream.SendPacket(packet);
StartSSL();
packet.Clear();
packet.WriteInteger((int) connectionFlags, 4);
}
#endif
packet.WriteInteger(maxSinglePacket, 4);
packet.WriteByte(8);
packet.Write(new byte[23]);
Authenticate();
// if we are using compression, then we use our CompressedStream class
// to hide the ugliness of managing the compression
//.........这里部分代码省略.........