/// <summary>
/// This function checks for any sleeping connections beyond a reasonable time and kills them.
/// Since .NET appears to have a bug with how pooling MySQL connections are handled and leaves
/// too many sleeping connections without closing them, we will kill them here.
/// </summary>
/// iMinSecondsToExpire - all connections sleeping more than this amount in seconds will be killed.
/// <returns>integer - number of connections killed</returns>
static public int KillSleepingConnections(int iMinSecondsToExpire)
{
string strSQL = "show processlist";
System.Collections.ArrayList m_ProcessesToKill = new ArrayList();
OdbcConnection myConn = new OdbcConnection(Global.strDBServer);
OdbcCommand myCmd = new OdbcCommand(strSQL, myConn);
OdbcDataReader MyReader = null;
try
{
myConn.Open();
// Get a list of processes to kill.
MyReader = myCmd.ExecuteReader();
while (MyReader.Read())
{
// Find all processes sleeping with a timeout value higher than our threshold.
int iPID = Convert.ToInt32(MyReader["Id"].ToString());
string strState = MyReader["Command"].ToString();
int iTime = Convert.ToInt32(MyReader["Time"].ToString());
if (strState == "Sleep" && iTime >= iMinSecondsToExpire && iPID > 0)
{
// This connection is sitting around doing nothing. Kill it.
m_ProcessesToKill.Add(iPID);
}
}
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
There's no way that I'm teaching you how to use the code that you're copying from me. If you cannot figure it out then just don't use it.
Thank you my friend Fang Do you think these codes eliminate the problem
They do. I ran it with a block test and the connections were killed successfully (in the exception to the one connection that it was using to kill the connections- which is killed on the next execution of the void).
Quote:
Originally Posted by marlyandedsel
Fang should I call this KillConnections.Kill(); every reading or opening the database?
No. You should make a new thread and call it "ServerManagement" (if you don't already have a server management thread that manages server cleanups and runs about twice a minute). Definitely don't call this to kill connections every time mysql is executed.
Call it to kill after every time you query something.... and see what happens ^^
Fang already gave you a good start... it's up to you how to use it...
i've swiched to flatfile database oO... works wonderfully! ;D
i have error Error 1 'Conquer_Online_Server.Database.DataHolder.Connect ionString' is inaccessible due to its protection level C:\Users\Administrator\Desktop\fixed\Source\cleanm ysql.cs 15 98 Conquer_Online_Server_x86
in public static void Kill()
{
string command = "SHOW processlist";
List<ulong> processes = new List<ulong>();
MySqlConnection conn = new MySqlConnection(Conquer_Online_Server.Database.Dat aHolder.ConnectionString);
MySqlCommand cmd = new MySqlCommand(command, conn);
MySqlDataReader reader = null;
[Release] Neo305´s Easy WoW Server Handler 4.0.6a 04/26/2013 - WoW Private Server - 61 Replies Neo305´s Easy WoW Server
http://img200.imageshack.us/img200/537/handlerr.p ng
Ich biete euch hier einen fertigen WoW Cataclysm 4.0.6a Server mit Handler.
Wie man ihn benutzt, steht in der README Datei.
[Release] Simple MsSql Handler 05/10/2011 - CO2 PServer Guides & Releases - 12 Replies I'm going back to MySql because I like it better. Here's the sql handler I was using that works with Sql Express (When you install Visual Studio):
namespace 数据库
{
using System;
using System.Data.SqlClient;
public static class Connection
{
Dauer MySQl Error mit 2.4.3 Mangos Handler! 03/11/2011 - WoW Private Server - 1 Replies so ich bin langsam am verzweifeln -_-
ich hab meine pts fertig, einzige prob was ich habe, jedesmal wenn ich meinen pc neustarte oder herunterfahre wieder hochfahre, starte ich meinen server und kriege dauernd "could not connect to mysql database" fehler ....
da ist ne datei "exemod.dll" sie enthält angeblich einen virus mir wurde gesagt das is ne fehlmeldung, sie wird öfters gelöscht, und glaube es liegt daran das ich server net starten kann, musste ihn immer neuinstallieren das ich ihn...
[Release] event handler / system message for 5165 source 05/01/2010 - CO2 PServer Guides & Releases - 10 Replies i was partially made this and completed by pringle, i dont know if pringle is in here in this forum. but still credit to him.
Go to Program.cs and find:public static Random Rnd = new Random();
Above this add:public static DateTime SystemMsgTime = new DateTime();
scroll down and you found this static void ServerStuff_Execute()
{
try
{
if (World.BroadCastCount > 0 && DateTime.Now > World.LastBroadCast.AddMinutes(1))
{