大概是这样的思路,扫描2000+的MySQL服务器,通过我的弱口令表去挨个连接他们(大概100个账户),看看能否成功,如果成功则证明检查不合格。共5个thread,一个thread中包含一个大循环遍历账户表,然后每次new 一个DataBaseInfo ,调用ConnectDatabase()这个来判断是否成功。当运行一段时间后,出现Communications link failure,最终所有的线程都会停止在ConnectDatabase()中,不抛异常,不停止。用的jdk1.5
public class DataBaseInfo
{
//do more
public boolean ConnectDatabase()
{
try
{
Class.forName(driver);
if (conn!=null)
{
conn.close();
}
DriverManager.setLoginTimeout(120);
conn=DriverManager.getConnection(this.Url,this.Account,this.Password);
//SimpleLogger.Write("Succeeded connecting to the Database!");
conn.close();
return true;
}
catch(Exception e)
{
//SimpleLogger.WriteError("Database: Error:");
System.out.println(this.Url+this.Account+this.Password+"---"+e.getMessage());
e.printStackTrace();
this.Close();
return false;
}
}
}
public class DataBaseInfo
{
//do more
public boolean ConnectDatabase()
{
try
{
Class.forName(driver);
if (conn!=null)
{
conn.close();
}
DriverManager.setLoginTimeout(120);
conn=DriverManager.getConnection(this.Url,this.Account,this.Password);
//SimpleLogger.Write("Succeeded connecting to the Database!");
conn.close();
return true;
}
catch(Exception e)
{
//SimpleLogger.WriteError("Database: Error:");
System.out.println(this.Url+this.Account+this.Password+"---"+e.getMessage());
e.printStackTrace();
this.Close();
return false;
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货