檢查c3p0數據源鏈接數狀況

<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.mchange.v2.c3p0.PooledDataSource"%>
<%@page import="com.mchange.v2.c3p0.ComboPooledDataSource"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script language="JavaScript"> 
function myrefresh() 
{ 
       window.location.reload(); 
} 
setTimeout('myrefresh()',1000); //指定1秒刷新一次 
</script>
</head>
<body>
<%
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
ComboPooledDataSource ds = (ComboPooledDataSource)ctx.getBean("dataSource");
%>
<br>
主數據源:<br>
最大鏈接數:<%=ds.getMaxPoolSize() %>
最小鏈接數:<%=ds.getMinPoolSize() %>
正在使用鏈接數:<%=ds.getNumBusyConnections() %>
空閒鏈接數:<%=ds.getNumIdleConnections() %>
總鏈接數:<%=ds.getNumConnections() %>
<br>



</body>
</html>
相關文章
相關標籤/搜索