c3p0 运行50次后报错了 大侠帮忙看看
这是我配置的c3p0
package com.forward.five.untils;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.sql.Statement;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class C3p0Until {
/***
* 连接数据库用到的常量
*/
private static ComboPooledDataSource cpd = null;
final String className="com.mysql.jdbc.Driver";
final String url="jdbc:mysql://127.0.0.1:3306/manager";
final String username="root";
final String password="";
private Connection conn=null;
private ResultSet rs=null;
private Statement st=null;
/**
* 声明本类的对象
*/
private static C3p0Until cp = null ;
/**
* 构造函数
* 配置c3p0
*/
private C3p0Until(){
cpd = new ComboPooledDataSource();
cpd.setUser(username);
cpd.setPassword(password);
cpd.setJdbcUrl(url);
try {
cpd.setDriverClass(className);
} catch (PropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cpd.setInitialPoolSize(20);
cpd.setMaxPoolSize(200);
cpd.setMinPoolSize(10);
cpd.setMaxStatements(0);
cpd.setMaxIdleTime(0);
//cpd.setMaxStatements(50);
}
/**
* 加锁
* 类的入口
* @return
*/
public synchronized static C3p0Until getC3p0Until(){
if(cp == null){
cp = new C3p0Until();
}
return cp;
}
/**
* 连接数据库
* @return
* @throws
ClassNotFoundException
* @throws
SQLException
*/
public Connection getConnection() throws Class
NotFoundException, SQLException{
return cpd.getConnection();
}
/**
* 执行sql语句
* @param sql
* @return
* @throws SQLException
* @throws ClassNotFoundException
*/
public ResultSet executeQuery(String sql) throws SQLException, ClassNotFoundException{
conn=this.getConnection();
st=conn.createStatement();
return rs=st.executeQuery(sql);
}
/**
* 关闭数据库
* @param rs
* @param st
* @param conn
*/
public void close(ResultSet rs, Statement st, Connection conn) {
try {
if (rs != null)
rs.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (st != null)
st.close();
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (conn != null)
try {
conn.close();
}