<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## Inerceptor BeetlSql可以在執行sql前后執行一系列的Intercetor,從而有機會執行各種擴展和監控,這比通過過數據庫連接池做監控更加容易。如下Interceptor都是有可能的 - 監控sql執行較長時間語句,打印并收集。TimeStatInterceptor 類完成 - 對每一條sql語句執行后輸出其sql和參數,也可以根據條件只輸出特定sql集合的sql。便于用戶調試。DebugInterceptor,Slf4JLogInterceptor完成,或者子類SimpleDebugInterceptor - 有機會在執行jdbc查詢前更改sql,更改參數等,甚至可以設置ThreadLocal參數從而在ConnectionSource子類里更改數據源 - 跟蹤執行的sql和響應的參數 - 緩存功能(自帶SimpleCacheInterceptor),可以通過before直接取得緩存結果而不需要查詢JDBC,但需要注意的是,在DAO層緩存不如在Service層緩存更加靈活,很多web框架,比如SpringBoot 都支持桌子Service級別緩存 > DebugInterceptor ,Slf4JLogInterceptor類是常用類,會將sql和參數打印到控制臺.前者使用控制臺輸出,后者使用slf4j接口 你也可以自行擴展Interceptor類,來完成特定需求。 如下,在執行數據庫操作前會執行before,通過ctx可以獲取執行的上下文參數,數據庫成功執行后,會執行after方法,如果執行出錯,會調用exception ```java public interface Interceptor { public void before(InterceptorContext ctx); public void after(InterceptorContext ctx); public void exception(InterceptorContext ctx,Exception ex); } ``` InterceptorContext 如下,executeContext參數,也就包含了sqlId,實際得sql,是查詢還是修改,和實際得參數, 也包括執行結果result。對于查詢,執行結果是查詢返回的結果集條數,對于更新,返回的是成功條數, ```java private Map<String, Object> env = null; private ExecuteContext executeContext; ``` env變量可以用于InterceptorContext上下文保存臨時變量,比如TimeStatInterceptor,調用before,保存當前時間到env里。調用after,取出保存的時間,得出整個jdbc調用時長 ```java @Override public void before(InterceptorContext ctx) { if(!include(ctx.getExecuteContext().sqlId)){ return; } ctx.setEnv(new HashMap<>()); ctx.getEnv().put("stat.time", System.currentTimeMillis()); } @Override public void after(InterceptorContext ctx) { if(!include(ctx.getExecuteContext().sqlId)){ return; } long end = System.currentTimeMillis(); long start = (Long) ctx.get("stat.time"); if ((end - start) > max) { ExecuteContext executeContext = ctx.getExecuteContext(); print(executeContext.sqlId.toString(), executeContext.sqlResult.jdbcSql, executeContext.sqlResult.jdbcPara, (end - start)); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看