KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > db > SimpleProfilerHandler


1 package examples.db;
2
3 import jodd.datetime.JDateTime;
4 import jodd.db.profile.SqlProfileData;
5 import jodd.db.profile.SqlProfilerHandler;
6 import jodd.util.Util;
7
8 public class SimpleProfilerHandler implements SqlProfilerHandler {
9
10     public void onExecuteQuery(SqlProfileData spd) {
11         onExecute(spd);
12     }
13
14     public void onExecuteUpdate(SqlProfileData spd) {
15         onExecute(spd);
16     }
17
18     private synchronized void onExecute(SqlProfileData spd) {
19         StackTraceElement[] ste = Util.getStackTrace();
20         System.out.println("\n>>> sql profiling ");
21         System.out.println(">>> " + ste[3].getClassName() + "." + ste[3].getMethodName() + "():" + ste[3].getLineNumber());
22         System.out.println(">>> " + spd.getSqlQuery());
23         JDateTime gt = new JDateTime(spd.getQueryTime());
24         System.out.println(">>> " + gt + "ms");
25         System.out.println(">>> " + spd.getDuration() + "ms\n");
26     }
27 }
28
Popular Tags