public class ProfiledConnection extends AbstractConnection
Statistics of the profiled Connections can be obtained from the static methods of this class. Instances of this class are the actual wrappers that perform profiling.
Modifier and Type | Class and Description |
---|---|
static class |
ProfiledConnection.Type |
connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
Constructor and Description |
---|
ProfiledConnection(Connection connection)
Creates a new ProfiledConnection that wraps the specified connection.
|
Modifier and Type | Method and Description |
---|---|
static void |
addQuery(ProfiledConnection.Type type,
String sql,
long time)
Adds a query.
|
void |
close() |
Statement |
createStatement() |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
static double |
getAverageQueryTime(ProfiledConnection.Type type)
Returns the average amount of time spent executing the specified type
of query.
|
static double |
getQueriesPerSecond(ProfiledConnection.Type type)
Returns the average number of queries of a certain type that have been
performed per second since profiling started.
|
static long |
getQueryCount(ProfiledConnection.Type type)
Returns the total number database queries of a particular type performed.
|
static ProfiledConnectionEntry[] |
getSortedQueries(ProfiledConnection.Type type,
boolean sortByTime)
Returns an array of sorted queries (as ProfiledConnectionEntry objects) by type
|
static long |
getTotalQueryTime(ProfiledConnection.Type type)
Returns the total amount of time in milliseconds spent doing a particular
type of query.
|
CallableStatement |
prepareCall(String sql) |
CallableStatement |
prepareCall(String sql,
int i,
int i1) |
PreparedStatement |
prepareStatement(String sql) |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency) |
static void |
resetStatistics()
Reset all statistics.
|
static void |
start()
Start profiling.
|
static void |
stop()
Stop profiling.
|
abort, clearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStruct, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, isWrapperFor, nativeSQL, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, unwrap
public ProfiledConnection(Connection connection)
connection
- the Connection to wrap and collect stats for.public static void start()
public static void stop()
public static long getQueryCount(ProfiledConnection.Type type)
type
- the type of query to get the count for.type
performed.public static void addQuery(ProfiledConnection.Type type, String sql, long time)
type
- the type of the query.sql
- the insert sql string.time
- the length of time the query took in millisecondspublic static double getQueriesPerSecond(ProfiledConnection.Type type)
type
- the type of database query to check.public static double getAverageQueryTime(ProfiledConnection.Type type)
type
- the type of query.public static long getTotalQueryTime(ProfiledConnection.Type type)
type
- the type of query to check.public static ProfiledConnectionEntry[] getSortedQueries(ProfiledConnection.Type type, boolean sortByTime)
type
- the type of query to checksortByTime
- sort the resulting list by Time if true,
otherwise sort by count if false (default)public static void resetStatistics()
public void close() throws SQLException
close
in interface AutoCloseable
close
in interface Connection
close
in class AbstractConnection
SQLException
public Statement createStatement() throws SQLException
createStatement
in interface Connection
createStatement
in class AbstractConnection
SQLException
public PreparedStatement prepareStatement(String sql) throws SQLException
prepareStatement
in interface Connection
prepareStatement
in class AbstractConnection
SQLException
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement
in interface Connection
createStatement
in class AbstractConnection
SQLException
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement
in interface Connection
prepareStatement
in class AbstractConnection
SQLException
public CallableStatement prepareCall(String sql) throws SQLException
prepareCall
in interface Connection
prepareCall
in class AbstractConnection
SQLException
public CallableStatement prepareCall(String sql, int i, int i1) throws SQLException
prepareCall
in interface Connection
prepareCall
in class AbstractConnection
SQLException
Copyright © 2003–2019 Ignite Realtime. All rights reserved.