tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephens, Daniel" <Daniel.Steph...@TeleCheck.com>
Subject RE: DBCP Logging
Date Mon, 19 Feb 2007 21:22:46 GMT
We wrote a simple method to return some stats. It's kinda crude, and may not
be a 100% accurate, but here is what we did. Hope it helps. We used this
documentation here 

http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/dbcp/Basic
DataSource.html

public static void printDataSourceStats(DataSource ds,String dbname,
javax.servlet.jsp.JspWriter out) throws SQLException {
        BasicDataSource bds = (BasicDataSource) ds;
	try {
		 int bdsNumActive = bds.getNumActive();
		 int bdsMaxActive = bds.getMaxActive();
		 int bdsNumIdle = bds.getNumIdle();
		 long bdsMaxWait = bds.getMaxWait();
 		 String fontcolor = "";
		
		if (bdsNumActive <= 400) {
			 fontcolor = "<font color=green>";
		} else if (bdsNumActive > 400 && bdsNumActive <= 500) {
			 fontcolor = "<font color=orange>";
		} else {
			 fontcolor = "<font color=red>";
		}
		out.print("<table cellpadding='3' cellspacing='0'>");
			out.print("<tr>");
				out.print("<td class=v11 border_botdot
borderg_r>" + dbname + " DataSource</td>");
			out.print("</tr>");
			out.print("<tr>");
				out.print("<td height='24'
class='columnhead9 border_r' align='center' alt='connections that are
processing'># Active Connections</td>");
				out.print("<td height='24'
class='columnhead9 border_r' align='center' alt='total size of pool'>Maximum
Active Connections</td>");		
				out.print("<td height='24'
class='columnhead9 border_r' align='center' alt='connections that are idle
in the pool'># of Idle Connections</td>");
				out.print("<td height='24'
class='columnhead9 border_r' align='center'>Maxium Wait period before
timeout</td>");		
			out.print("</tr>");
			out.print("<tr>");
				out.print("<td class='v11 border_botdot
borderg_r' >"+fontcolor + bdsNumActive + "</font></td>");
				out.print("<td class='v11 border_botdot
borderg_r'>" + bdsMaxActive + "</td>");
				out.print("<td align='left' class='v11
border_botdot borderg_r'>" + bdsNumIdle + "</td>");
				out.print("<td align='left' class='v11
border_botdot borderg_r'>" + bdsMaxWait + "</td>");
			out.print("</tr>");
		out.print("</table>");
	} catch(Exception e) {
		e.printStackTrace(); 	
	}
 } 

-----Original Message-----
From: Yannick Haudry [mailto:yhaudry@gmail.com] 
Sent: Monday, February 19, 2007 2:37 PM
To: Tomcat Users List
Subject: Re: DBCP Logging

If your datasource is not managed through your container but application
driven, I guess Lambda probe (which is a great
application) will not be able to give you information about it ? Is there a
way to programmatically log the number of connections in use, etc ... ?

Thanks
Yannick

On 2/19/07, David Delbecq <delbd@oma.be> wrote:
> Lambda probe is a usefull webapplication you can deploy under tomcat 
> and that, amongst many features, allows you to see the state of your 
> connection pools.
>
> En l'instant précis du 02/19/07 14:40, news@swisslab.de s'exprimait en 
> ces termes:
> > Hello List,
> >
> > I've configured DBCP on my Tomcat 5.5.20 Installation.
> >     <Resource name="jdbc/myDB"
> >               auth="Container"
> >               type="javax.sql.DataSource"
> >          maxActive="10"
> >            maxIdle="2"
> >            maxWait="10000"
> >           username="aUser"
> >           password="secret"
> >    driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
> >            factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> >                
> > url="jdbc:sybase:Tds:194.111.13.30:5000/?charset=iso_1" />
> >
> > This runs great and I'm really happy with it until it comes to 
> > logging and/or monitoring.
> > What do I have to do if I want to know the state of the connection 
> > pool? How can I see how many connections are currently in use? Or - 
> > more generally - How can I set up logging for the pool?
> >
> > Thanks!
> >
> > Jan
> >
> > --------------------------------------------------------------------
> > - To start a new topic, e-mail: users@tomcat.apache.org To 
> > unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, 
> e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


-----------------------------------------
The information in this message may be proprietary and/or
confidential, and protected from disclosure.  If the reader of this
message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify First Data
immediately by replying to this message and deleting it from your
computer.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message