Call performance http://www.cnblogs.com/zfc2201/p/3786365.html for JAMon monitoring web engineering methods
This article often tells you how to monitor the web method call time. On this basis, if we want to monitor the SQL Execution time, we need to add the following Configuration:
1. Add a class, for example, com. allen. bookshop. common. MonitorDataSource.
Import java. io. printWriter; import java. SQL. connection; import java. SQL. SQLException; import javax. SQL. dataSource; import com. jamonapi. proxy. monProxyFactory; public class MonitorDataSource implements DataSource {private DataSource realDataSource; public void setRealDataSource (DataSource realDataSource) {this. realDataSource = realDataSource;} public DataSource getRealDataSource () {return realDataSource;} public Connection getConnection () throws SQLException {// represents the Connection return MonProxyFactory returned by realDataSource by jamon. monitor (realDataSource. getConnection ();} public Connection getConnection (String username, String password) throws SQLException {// represents the Connection return MonProxyFactory returned by realDataSource by jamon. monitor (realDataSource. getConnection (username, password);} public PrintWriter getLogWriter () throws SQLException {return realDataSource. getLogWriter ();} public int getLoginTimeout () throws SQLException {return realDataSource. getLoginTimeout ();} public void setLogWriter (PrintWriter out) throws SQLException {realDataSource. setLogWriter (out);} public void setLoginTimeout (int seconds) throws SQLException {realDataSource. setLoginTimeout (seconds );}}
2. Configure the Data source:
<bean id="dataSource" class="com.allen.bookshop.common.MonitorDataSource" destroy-method="close"> <property name="realDataSource" ref="basicDataSource"/> </bean>
<bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@192.168.0.11:1521:orcl" /> <property name="username" value="orcl" /> <property name="password" value="orcl" /> <property name="initialSize" value="20" /> <property name="maxActive" value="50" /> <property name="defaultAutoCommit" value="true" /> </bean>
Now that the configuration is complete, you can access: http: // localhost: 8080/bookshop/jamon/SQL. jsp to view the SQL Execution time.