关于Servlet控制数据库连接池的问题
我用Servlet写了一个数据库连接池的管理。在读取属性文件的时候老是出错。呵呵。。请大侠帮忙看看。
管理类的代码
import java.sql.*;
import java.util.*;
import java.util.Date;
import java.io.*;
public class DBConnectionManager {
static private DBConnectionManager instance;
static private int clients;
private Vector driverlist = new Vector();
private HashMap pools = new HashMap();
String poolname;
static synchronized public DBConnectionManager getInstance(){
if(instance == null){
instance = new DBConnectionManager();
}
return instance;
}
private DBConnectionManager(){
init();
}
private void init(){
InputStream is = getClass().getResourceAsStream( "/db.properties ");
Properties dbProp = new Properties();
try{
dbProp.load(is);
}catch(Exception e){
e.printStackTrace();
return;
}
LoadDrivers(dbProp);
creatPools(dbProp);
}
private void LoadDrivers(Properties Prop){
String driverClass = Prop.getProperty( "driver ");
StringTokenizer st = new StringTokenizer(driverClass);
while(st.hasMoreElements()){
String driverClassName = st.nextToken().trim();
try{
Driver driver = (Driver)Class.forName(driverClassName).newInstance();
DriverManager.registerDriver(driver);