jodd.db.profile
Class SqlUtilProfiler

java.lang.Object
  extended byjodd.db.SqlUtil
      extended byjodd.db.profile.SqlUtilProfiler

public class SqlUtilProfiler
extends SqlUtil

Profiles database access by measuring executeQuery and executeUpdate execution times. After measuring, a callback method in SqlProfilerHandler is called with profile data.

Usage is quite simple: instead of SqlUtil use SqlUtilProfiler. Before first usage, usually during initialization, assign handler field to an instance of the SqlProfilerHandler.

Note: java System.currentTimeMillis() is not very precise, so as query execution is longer, the duration is more precise, and the error is lower.

See Also:
SqlUtil

Field Summary
static SqlProfilerHandler handler
          Holds current profile handler.
 
Constructor Summary
SqlUtilProfiler(ConnectionPool cp)
          Overloaded constructor.
 
Method Summary
 java.sql.ResultSet executeQuery()
          Executes query and measures time.
 int executeUpdate()
          Executes update and measures time.
 
Methods inherited from class jodd.db.SqlUtil
close, close, closeAll, closeAll, commit, getAutoCommit, getDebugMode, getDefaultAutoCommit, getStoredAutoCommit, rollback, setArray, setAutoCommit, setBigDecimal, setBlob, setBoolean, setByte, setClob, setDate, setDebugMode, setDefaultAutoCommit, setDouble, setFloat, setInt, setLong, setSql, setSql, setStaticSql, setStaticSql, setString, setTimestamp, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handler

public static SqlProfilerHandler handler
Holds current profile handler. Must be set before first usage.

Constructor Detail

SqlUtilProfiler

public SqlUtilProfiler(ConnectionPool cp)
Overloaded constructor.

Parameters:
cp -
Method Detail

executeQuery

public java.sql.ResultSet executeQuery()
                                throws java.sql.SQLException
Executes query and measures time.

Overrides:
executeQuery in class SqlUtil
Returns:
sql query result
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate()
                  throws java.sql.SQLException
Executes update and measures time.

Overrides:
executeUpdate in class SqlUtil
Returns:
sql update result
Throws:
java.sql.SQLException


Jodd v0.24.5 Javadoc