通过以下DAO操作proxool连接池访问量大的时候,老是有问题?DAO如下:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.sql.CallableStatement;
public final class DAO implements DBsource,DAO
{
private static Connection conn=null;
private Statement st=null;
ResultSet rs=null;
PreparedStatement ps=null;
CallableStatement cs=null;
public DAO()
{
}
static{
try{
Class.forName( "org.logicalcobwebs.proxool.ProxoolDriver ");
}catch(Exception ex){
ex.printStackTrace();
}
}
private void getConn()
{
try{
conn = DriverManager.getConnection( "proxool.xml-test ");
//conn = DriverManager.getConnection(Url, username, password);
//conn.setAutoCommit(false);//支持事务
}catch (Exception ex){
ex.printStackTrace();
}
}
//负责建立状态通道
private Statement getStatement(){
try {
if(conn==null||conn.isClosed())
{
getConn();
}
st = conn.createStatement();
if(st==null)
{
st=getStatement();
}
}catch (SQLException ex) {
ex.printStackTrace();
}
return st;
}
//
public boolean doBatch(List SQLs){
boolean is=false;
getStatement();
try{
for(int i=0;i <SQLs.size();i++){
st.addBatch(SQLs.get(i).toString());
}
int[] a=st.executeBatch();
// for(int i=0;i <a.length;i++){