//打开数据库连接 获取
public Connection getConnection(String name) {
ConnectionPool pool = pools.get(name);
if(pool!=null) {
return pool.getConnection();
}
return null;
}
public Connection getConnection(String name, long time) {
ConnectionPool pool = pools.get(name);
if(pool!=null) {
return pool.getConnection(time);
}
return null;
}
//初始化
public void init() {
InputStream in = this.getClass().getResourceAsStream("资源文件");
Properties prop = new Properties();
try
{
prop.load(in);
}
catch (IOException e)
{
e.printStackTrace();//log
}
String logFile = prop.getProperty("logfile", "DBConection.log");
try {
log = new PrintWriter(new FileWriter(logFile, true), true);
} catch(IOException e) {
System.out.println("");
log = new PrintWriter(System.err);
}
this.loadDrivers(prop);
this.createPools(prop);
}
public Connection getConnection(String name) {
ConnectionPool pool = pools.get(name);
if(pool!=null) {
return pool.getConnection();
}
return null;
}
public Connection getConnection(String name, long time) {
ConnectionPool pool = pools.get(name);
if(pool!=null) {
return pool.getConnection(time);
}
return null;
}
//初始化
public void init() {
InputStream in = this.getClass().getResourceAsStream("资源文件");
Properties prop = new Properties();
try
{
prop.load(in);
}
catch (IOException e)
{
e.printStackTrace();//log
}
String logFile = prop.getProperty("logfile", "DBConection.log");
try {
log = new PrintWriter(new FileWriter(logFile, true), true);
} catch(IOException e) {
System.out.println("");
log = new PrintWriter(System.err);
}
this.loadDrivers(prop);
this.createPools(prop);
}
(sunxuecheng66) 等 级:
结帖率:0.00% 兄弟 , 我真不理解你是怎么向的。 ..........................................