javaGrowing

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            92 隨筆 :: 33 文章 :: 49 評論 :: 0 Trackbacks
          利用P6SPY +SQL Profiler記錄、統計web app對數據庫的操作。 弄hibernate時,想顯示sql語句,可以設置show_sql為true來達到這個目的,但是參數值全是像PreparedStatement一樣,用?來代替的。 用p6spy可以達到顯示的那些參數原值的目的,但可讀性差??梢岳肧QL Profiler來處理這個事情。 p6spy: http://www.p6spy.com SQL Profile: http://www.jahia.net/jahia/page597.html p6spy安裝: * 將p6spy.jar放到WEB-INF/lib目錄下,將spy.properties放到WEB-INF/classes目錄下。 * 修改你 原有 JDBC Driver為:com.p6spy.engine.spy.P6SpyDriver * 修改 spy.properties 中的 realdriver 值為 原有 的JDBC Driver,比如我的是:com.mysql.jdbc.Driver * 完成,運行web server。 我的日志記錄產生在 %TOMCAT_HOME%\bin下,此log位置可以能過修改 logfile = x:\x_dir\spy.log 來控制 打開看看,看里面的日志是不是看起來比較不爽?下面我們安裝SQL Profiler來讓自已的視線爽一點。 SQL Profiler安裝:(須p6spy成功安裝) * 將SQL Profiler自帶的spy.properties覆蓋原來的classes目錄下文件 * 修改現在spy.properties中realdriver 值為 原有 的JDBC Driver 看后看看readme注意這幾句 ^__^ : 1. Start the GUI 2. Start the webapp, in starts doing some JDBC requests we will ignore 3. Press the "reset" button on the GUI 4. Make a request to the webapp 5. Press the "pause" button after the request has finished executing 6. Press the "report" button to save profiling results as a CSV file * 我們先用java -jar sqlprofiler.jar 運行 sql profiler * 然后啟動web server :-) 一切盡在眼前了吧? 當然,p6spy 和 sql profiler 能做的不止這些,sql profiler還能根據你的query來幫你生成建立合適的index功能等等。
          posted on 2009-10-19 15:01 javaGrowing 閱讀(423) 評論(0)  編輯  收藏 所屬分類: java學習
          主站蜘蛛池模板: 青浦区| 马边| 武威市| 吉安县| 小金县| 襄城县| 深圳市| 林周县| 开阳县| 库伦旗| 乌鲁木齐市| 陆丰市| 东山县| 普兰店市| 剑河县| 汉川市| 大余县| 湾仔区| 稻城县| 常山县| 凤冈县| 宝清县| 襄樊市| 商南县| 沁阳市| 罗江县| 屯门区| 左云县| 通海县| 堆龙德庆县| 海阳市| 宁明县| 札达县| 石泉县| 区。| 塔城市| 定结县| 昭苏县| 大竹县| 柘城县| 教育|