老玉米:
public class DBConnhelper ,这里面封装了一个乌烟推荐的ConnectionPool
[阅读: 443] 2006-08-22 10:18:02
/**
*
*/
package bjepb.promng;
import com.softtech.jdbc.ConnectionPool;
import com.softtech.jdbc.SQLExecutor;
import com.softtech.jdbc.SQLResults;
/**
* @author Administrator
*
*/
public class DBConnhelper {
private static final int numPooledCon = 10;
private static final String driver = "com.mysql.jdbc.Driver";
private static final String url = "jdbc:mysql://localhost:3306/management";
private static final String user = "root";
private static final String password = "zhu88jie";
private static ConnectionPool conPool = null;
/**
*
*/
public DBConnhelper() {
// TODO Auto-generated constructor stub
}
private static synchronized ConnectionPool getConnectionPool()
{
if (conPool == null)
{
conPool = new ConnectionPool(numPooledCon,driver,url,user,password);
}
return conPool;
}
public static SQLResults excute(String sql)
{
conPool = getConnectionPool();
SQLExecutor sqlExec = new SQLExecutor(conPool);
SQLResults rs = sqlExec.runQuery(sql);
sqlExec.releaseConnection();
return rs;
}
public static SQLExecutor getSqlExec()
{
return new SQLExecutor(conPool);
}
}
民主不同于专制,不需要强加于人。--- 賴斯
大道之行也,天下为公,选贤与能,讲信修睦。故人不独亲其亲,不独子其子,使老有所终,壮有所用,幼有所长,矜、寡、孤、独、废疾者,皆有所养。男有分,女有归。货恶其弃於地也,不必藏於己;力恶其不出於身也,不必为己。是故,谋闭而不兴,盗窃乱贼而不作,故外户而不闭,是谓大同。--《礼运·大同篇》