当前位置: 技术问答>java相关
急:高分求 连接池源程序 以及 连接池使用举例程序
来源: 互联网 发布时间:2015-08-16
本文导语: 各位,谁有访问Oracle数据库的连接池源程序,以及连接池使用的例子,请发给我一份,急用!多谢!(“货”到付“款”!^_^) email:easydw@21cn.com | ----------------------------------------------------- Java程序 impor...
各位,谁有访问Oracle数据库的连接池源程序,以及连接池使用的例子,请发给我一份,急用!多谢!(“货”到付“款”!^_^)
email:easydw@21cn.com
email:easydw@21cn.com
|
-----------------------------------------------------
Java程序
import java.util.*;
import java.sql.*;
public class ConnPool {
private static final int defaultMaxConnections=3;//默认最大连接对象数;
private Vector freeConnections;//存放还未被配置出去的连接对象;
private Hashtable boundConnections;//存放目前正被使用的连接对象;
private String driverName;
private String jdbcURL;
private String username;
private String password;
private int maxConnections;//最大连接对象数;
public ConnPool(int numConnections) {
maxConnections=numConnections;
boundConnections=null;
freeConnections=null;
driverName="";
jdbcURL="";
username="";
password="";
}
public ConnPool() {
this(defaultMaxConnections);
}
public void openDB(String drvName,String url,String uname,String passwd) throws SQLException {
try {
boundConnections=new Hashtable(maxConnections);
freeConnections=new Vector(maxConnections);
Class.forName(drvName);
for(int i=0;i
Java程序
import java.util.*;
import java.sql.*;
public class ConnPool {
private static final int defaultMaxConnections=3;//默认最大连接对象数;
private Vector freeConnections;//存放还未被配置出去的连接对象;
private Hashtable boundConnections;//存放目前正被使用的连接对象;
private String driverName;
private String jdbcURL;
private String username;
private String password;
private int maxConnections;//最大连接对象数;
public ConnPool(int numConnections) {
maxConnections=numConnections;
boundConnections=null;
freeConnections=null;
driverName="";
jdbcURL="";
username="";
password="";
}
public ConnPool() {
this(defaultMaxConnections);
}
public void openDB(String drvName,String url,String uname,String passwd) throws SQLException {
try {
boundConnections=new Hashtable(maxConnections);
freeConnections=new Vector(maxConnections);
Class.forName(drvName);
for(int i=0;i