首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

C3P0运行几天后报错,并挂掉 请指点

2011-11-30 
C3P0运行几天后报错,并挂掉 请高手指点指点C3P0运行几天后报错,并挂掉报了这样的错误:WARN [com.mchange.v

C3P0运行几天后报错,并挂掉 请高手指点指点
C3P0运行几天后报错,并挂掉
报了这样的错误:

WARN [com.mchange.v2.resourcepool.BasicResourcePool] - <com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@e8f8c5 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception: >
java.sql.SQLException: Io 异常: Connection reset

请问这是什么原因呢?

[解决办法]
import java.sql.Connection;

import com.mchange.v2.c3p0.ComboPooledDataSource;

public class C3p0Util {
static String driver_2005="com.microsoft.sqlserver.jdbc.SQLServerDriver";
static String url_2005="jdbc:sqlserver://localhost:1433;databasename=pubs";

static String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
static String url = "jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs";
static String user = "sa";
static String password = null;

static ComboPooledDataSource cpds = null;

static {
try {
cpds = new ComboPooledDataSource();
//driver 2000
//cpds.setDriverClass(driver);
//cpds.setJdbcUrl(url);
//driver2005
cpds.setDriverClass(driver_2005);
cpds.setJdbcUrl(url_2005);
cpds.setUser(user);
cpds.setPassword(password);
} catch (Exception e) {
e.printStackTrace();
}
}

//获取连接
public static Connection getConnection() {
Connection conn = null;
try {
conn = cpds.getConnection();
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}

public static void main(String[] args) {
Connection conn = C3p0Util.getConnection();
System.out.println(conn);
}
}


c3p0.jar要
[解决办法]
顶,写一个测试类调通后然后再使用,这样方便一点建议用main方法

热点排行