1 3 package jodd.db; 4 5 import java.sql.Connection ; 6 import java.sql.ResultSet ; 7 8 11 public class DbProfiledQuery extends DbQuery { 12 13 public DbProfiledQuery(Connection conn, String sql) { 14 super(conn, sql); 15 } 16 17 public DbProfiledQuery(Connection conn, String sqlString, DbQueryMode mode) { 18 super(conn, sqlString, mode); 19 } 20 21 public DbProfiledQuery(DbSession session, String sqlString, DbQueryMode mode) { 22 super(session, sqlString, mode); 23 } 24 25 public DbProfiledQuery(DbSession session, String sqlString) { 26 super(session, sqlString); 27 } 28 29 public DbProfiledQuery(String sqlString, DbQueryMode mode) { 30 super(sqlString, mode); 31 } 32 33 public DbProfiledQuery(String sqlString) { 34 super(sqlString); 35 } 36 37 39 long start; 40 long elapsed = -1; 41 42 public int executeUpdate() { 43 start = System.currentTimeMillis(); 44 int result = super.executeUpdate(); 45 elapsed = System.currentTimeMillis() - start; 46 return result; 47 } 48 49 public ResultSet execute() { 50 start = System.currentTimeMillis(); 51 ResultSet result = super.execute(); 52 elapsed = System.currentTimeMillis() - start; 53 return result; 54 } 55 56 60 public long getExecutionElapsedTime() { 61 return elapsed; 62 } 63 64 66 67 public String getQueryString() { 68 StringBuffer result = new StringBuffer (super.getQueryString()); 69 if (elapsed != -1) { 70 result.append("\nExecution time: ").append(elapsed).append("ms."); 71 } 72 return result.toString(); 73 } 74 75 } 76 | Popular Tags |