jdbc.maxPoolSize=100
jdbc.minPoolSize=2
jdbc.initialPoolSize=2
jdbc.acquireIncrement=2
jdbc.maxStatements=1000
jdbc.maxIdleTime=300
jdbc.checkoutTimeout=5000
jdbc.maxConnectionAge=500
这是我的设置
---------------------------------------------------------------------
private final static Log log = LogFactory.getLog(DataSourceManager.class);
private final static ThreadLocal<Connection> conns = new ThreadLocal<Connection>();
private static DataSource dataSource;
private static boolean show_sql = false;初始化代码:
try {
if (dbProperties == null) {
dbProperties = new Properties();
dbProperties.load(DataSourceManager.class
.getResourceAsStream("db.properties"));
}
Properties cp_props = new Properties();
for (Object key : dbProperties.keySet()) {
String skey = (String) key;
if (skey.startsWith("jdbc.")) {
String name = skey.substring(5);
cp_props.put(name, dbProperties.getProperty(skey));
if ("show_sql".equalsIgnoreCase(name)) {
show_sql = "true".equalsIgnoreCase(dbProperties
.getProperty(skey));
}
}
}
dataSource = (DataSource) Class.forName(
cp_props.getProperty("datasource")).newInstance();
if (dataSource.getClass().getName().indexOf("c3p0") > 0) {
// Disable JMX in C3P0
System.setProperty(
"com.mchange.v2.c3p0.management.ManagementCoordinator",
"com.mchange.v2.c3p0.management.NullManagementCoordinator");
}
log.info("Using DataSource : " + dataSource.getClass().getName());
BeanUtils.populate(dataSource, cp_props); Connection conn = getConnection();
DatabaseMetaData mdm = conn.getMetaData();
log.info("Connected to " + mdm.getDatabaseProductName() + " "
+ mdm.getDatabaseProductVersion());
closeConnection();
} catch (Exception e) {
// throw new DBException(e);
}昨天监控到现在。。发现有4个超时的连接,都是1万多秒的
这种连接应该是属于泄漏了把。。想问下为什么C3p0的设置不起效?我设置了maxConnectionAge也没看到起效。。
jdbc.minPoolSize=2
jdbc.initialPoolSize=2
jdbc.acquireIncrement=2
jdbc.maxStatements=1000
jdbc.maxIdleTime=300
jdbc.checkoutTimeout=5000
jdbc.maxConnectionAge=500
这是我的设置
---------------------------------------------------------------------
private final static Log log = LogFactory.getLog(DataSourceManager.class);
private final static ThreadLocal<Connection> conns = new ThreadLocal<Connection>();
private static DataSource dataSource;
private static boolean show_sql = false;初始化代码:
try {
if (dbProperties == null) {
dbProperties = new Properties();
dbProperties.load(DataSourceManager.class
.getResourceAsStream("db.properties"));
}
Properties cp_props = new Properties();
for (Object key : dbProperties.keySet()) {
String skey = (String) key;
if (skey.startsWith("jdbc.")) {
String name = skey.substring(5);
cp_props.put(name, dbProperties.getProperty(skey));
if ("show_sql".equalsIgnoreCase(name)) {
show_sql = "true".equalsIgnoreCase(dbProperties
.getProperty(skey));
}
}
}
dataSource = (DataSource) Class.forName(
cp_props.getProperty("datasource")).newInstance();
if (dataSource.getClass().getName().indexOf("c3p0") > 0) {
// Disable JMX in C3P0
System.setProperty(
"com.mchange.v2.c3p0.management.ManagementCoordinator",
"com.mchange.v2.c3p0.management.NullManagementCoordinator");
}
log.info("Using DataSource : " + dataSource.getClass().getName());
BeanUtils.populate(dataSource, cp_props); Connection conn = getConnection();
DatabaseMetaData mdm = conn.getMetaData();
log.info("Connected to " + mdm.getDatabaseProductName() + " "
+ mdm.getDatabaseProductVersion());
closeConnection();
} catch (Exception e) {
// throw new DBException(e);
}昨天监控到现在。。发现有4个超时的连接,都是1万多秒的
这种连接应该是属于泄漏了把。。想问下为什么C3p0的设置不起效?我设置了maxConnectionAge也没看到起效。。
解决方案 »
- 万分感谢各门大虾 加急快件 struts+ajax问题 先谢谢了
- 如何创建一个普通的socket连接,可以检测到服务器出现未启动或者出现异常
- SSH 空指针
- 有没有这样的软件?
- 问一个关于intellij中生成webservice程序的问题
- Hibernate的作用到底是什么,不应该只是代替我们写sql语句吧
- 在JBoss.net集成的juddi中发布服务的问题 高分求教
- Tapestry PropertySelection组件的问题!(急等)
- tomcat 中用deploy命令, 把文件夹搞丢了, 求救!!!!!
- 怎么在控制台输出模拟银行取钱过程?
- 一个简单的程序 java通过socket传递对象,接受端只能接收到的第一个对象
- CXF客户端返回错误编码401
http://www.mchange.com/projects/c3p0/index.html#using_combopooleddatasource实例化的c3p0 datasource是什么?怎么实例化的?参数配置上面介绍都很详细