JAMon监控SQL执行时间
JAMon监控web工程方法的调用性能 http://www.cnblogs.com/zfc2201/p/3786365.html
这往往篇文章主要告诉大家如何监控web方法调用时间,在这个基础这上,如果我们想要监控sql的执行时间,需要增加如下的配置:
1.增加一个类,假设是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
{
// 表示由jamon来代理realDataSource返回的Connection
return MonProxyFactory.monitor( realDataSource.getConnection() );
} public Connection getConnection( String username, String password )
throws SQLException
{
// 表示由jamon来代理realDataSource返回的Connection return MonProxyFactory.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.对数据源进行配置:
<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>
至此,配置完成,现在可以访问:http://localhost:8080/bookshop/jamon/sql.jsp查看sql的执行时间了。
JAMon监控SQL执行时间的更多相关文章
- 用脚本定时监控SQL Server主从一致性
用脚本定时监控SQL Server主从一致性 首先说一下我们的环境 我们使用的是事务复制,复制是单向的,主服务器和从服务器都在同一个机房,当然不同机房也可以,只需要改一下IP和端口 下面的脚本在我们的 ...
- DBA 需要知道N种对数据库性能的监控SQL语句
--DBA 需要知道N种对数据库性能的监控SQL语句 -- IO问题的SQL内部分析 下面的DMV查询可以来检查当前所有的等待累积值. Select wait_type, waiting_tasks_ ...
- 监控SQL:执行表中所有sql语句、记录每个语句运行时间(3)
原文:监控SQL:执行表中所有sql语句.记录每个语句运行时间(3) 通过执行一个 带参数的存储过程 exec OpreateTB('OpreateUser','IsRun') 更新表的数据 表 ...
- 监控SQL:通过SQL Server的DDL触发器来监控数据库结构的变化(1)
原文:监控SQL:通过SQL Server的DDL触发器来监控数据库结构的变化(1) 如果你要同步不同数据库之间的数据,首先会想到的是数据库复制技术,但如果让你同步数据库的结构,你会想到什么呢? 下面 ...
- 监控 SQL Server (2005/2008) 的运行状况
Microsoft SQL Server 2005 提供了一些工具来监控数据库.方法之一是动态管理视图.动态管理视图 (DMV) 和动态管理函数 (DMF) 返回的服务器状态信息可用于监控服务器实例的 ...
- Performance Monitor3:监控SQL Server的内存压力
SQL Server 使用的资源受到操作系统的调度,同时,SQL Server在内部实现了一套调度算法,用于管理从操作系统获取的资源,主要是对内存和CPU资源的调度.一个好的数据库系统,必定在内存中缓 ...
- JavaMelody监控SQL
前言 前面讲过了Javamelody的基本配置,这里简单的介绍下,如何使用Javamelody来监控JDBC以及SQL. 手码不易,转载请注明:xingoo 在网上搜索很多资料,仅有开源社区上的两篇帖 ...
- 第三篇——第二部分——第六文 监控SQL Server镜像
原文:第三篇--第二部分--第六文 监控SQL Server镜像 原文出处:http://blog.csdn.net/dba_huangzj/article/details/26846203 要优化, ...
- java监控函数执行时间
java监控函数执行时间 http://blog.csdn.net/ycg01/article/details/1467542 java监控函数执行时间 标签: javathreadclassstri ...
随机推荐
- [Leetcode Week6]Linked List Cycle
Linked List Cycle 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/linked-list-cycle/description/ Des ...
- 【LA3461】Leonardo的笔记本
白书例题. #include<bits/stdc++.h> using namespace std; ],vis[],cnt[]; inline int read(){ ,x=;char ...
- 【luogu2574】xor的艺术
一道无聊的线段树题,写着玩玩而已…… #include<bits/stdc++.h> #define N 1000010 #define lson (o<<1) #define ...
- python基础(字符串常用、数字类型转换、基本运算符与流程控制)
一.字符串常用操作: #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "Z'N'Y" # Date: 2 ...
- Python 进阶 之 闭包变量
在闭包内访问外部变量的方法有两种: 1:变量前加nonlocal(仅支持Python3) 2:用列表来代替变量.即使是只有一个元素的数组,否则会报错.
- Android:Activity统一堆栈管理(实现随时finish特定或是所有Activty)
直接上代码: Activity管理类:AppManager /** * 应用程序Activity管理类:用于Activity管理和应用程序退出 * * @author BiHaidong * @ver ...
- k-密码
链接:https://www.nowcoder.com/acm/contest/90/K来源:牛客网 题目描述 ZiZi登录各种账号的时候,总是会忘记密码,所以他把密码都记录在一个记事本上.其中第一个 ...
- centos6.5 python2.7.8 安装scrapy总是出错【解决】
pip install Scrapy 报错: UnicodeDecodeError: 'ascii' codec can't decode byte 0xb4 in position python s ...
- codeforces Round #441 C Classroom Watch【枚举/注意起点】
C. time limit per test 1 second memory limit per test 512 megabytes input standard input output stan ...
- HDU 2553 N皇后问题【棋盘型DFS】
N皇后问题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...