JAMon monitors SQL Execution time

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.