sp;url 数据库连接url
* @param user 用户名
* @param password 密码
*/
public ConnectionParam(String driver,String url,String user,String password)
{
this.driver = driver;
this.url = url;
this.user = user;
this.password = password;
}
public String getDriver() {
return driver;
}
public String getPassword() {
return password;
}
public String getUrl() {
return url;
}
public String getUser() {
return user;
}
public void setDriver(String driver) {
this.driver = driver;
}
public void setPassword(String password) {
this.password = password;
}
public void setUrl(String url) {
this.url = url;
}
public void setUser(String user) {
this.user = user;
}
/**
* @see java.lang.Object#clone()
*/
public Object clone(){
ConnectionParam param = new ConnectionParam(driver,url,user,password);
return param;
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if(obj instanceof ConnectionParam){
ConnectionParam param = (ConnectionParam)obj;
return ((driver.compareToIgnoreCase(param.getDriver()) == 0)&&
(url.compareToIgnoreCase(param.getUrl()) == 0)&&
(user.compareToIgnoreCase(param.getUser()) == 0)&&
(password.compareToIgnoreCase(param.getPassword()) == 0));
}
return false;
}
}
FactoryMangeThread.java
/*
* Created on 2003-5-13
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package scut.ailab.connectionpool;
/**
* @author youyongming
*
*/
//连接池调度线程
public class FactoryMangeThread implements Runnable {
ConnectionFactory cf = null;
long delay = 1000;
public FactoryMangeThread(ConnectionFactory obj)
{
cf = obj;
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
while(true){
try{
Thread.sleep(delay);
}
catch(InterruptedException e){}
System.out.println("eeeee");
//判断是否已经关闭了工厂,那就退出监听
if (cf.isCreate())
cf.schedule();
else
System.exit(1);
}
}
}
FactoryParam.java
/*
* Created on 2003-5-13
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package scut.ailab.connectionpool;
/**
* @author youyongming
*
*/
//连接池工厂参数
public class FactoryParam {
//最大连接数
private int