public class ProfiledConnection extends ConnectionAdapter
Title: 常用代码打包
Description: Wraps a Connection object and collects statistics about the database queries that are performed.
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.
Copyright: Copyright (c) 2006
Company: www.justdos.net
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DELETE
Constant for DELETE database queries.
|
static int |
INSERT
Constant for INSERT database queries.
|
static int |
SELECT
Constant for SELECT database queries.
|
static int |
UPDATE
Constant for UPDATE database queries.
|
connection| 构造器和说明 |
|---|
ProfiledConnection(Connection connection)
Creates a new ProfiledConnection that wraps the specified connection.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
addQuery(int type,
String sql,
long time) |
void |
close() |
Statement |
createStatement() |
Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
static double |
getAverageQueryTime(int type)
Returns the average amount of time spent executing the specified type
of query.
|
static double |
getQueriesPerSecond(int type)
Returns the average number of queries of a certain type that have been
performed per second since profiling started.
|
static long |
getQueryCount(int type)
Returns the total number database queries of a particular type performed.
|
static ProfiledConnectionEntry[] |
getSortedQueries(int type,
boolean sortByTime)
Returns an array of sorted queries (as ProfiledConnectionEntry objects) by type
|
static long |
getTotalQueryTime(int type)
Returns the total amount of time in milliseconds spent doing a particular
type of query.
|
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, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setTransactionIsolation, setTypeMap, toString, unwrappublic static final int SELECT
public static final int UPDATE
public static final int INSERT
public static final int DELETE
public ProfiledConnection(Connection connection) throws SQLException
connection - the Connection to wrap and collect stats for.SQLExceptionpublic static void start()
public static void stop()
public static long getQueryCount(int type)
type - the type of query to get the count for.public static void addQuery(int type,
String sql,
long time)
sql - the insert sql string.time - the length of time the query took in millisecondspublic static double getQueriesPerSecond(int type)
type - the type of database query to check.public static double getAverageQueryTime(int type)
type - the type of query.public static long getTotalQueryTime(int type)
type - the type of query to check.public static ProfiledConnectionEntry[] getSortedQueries(int 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 在接口中 AutoCloseableclose 在接口中 Connectionclose 在类中 ConnectionAdapterSQLExceptionpublic Statement createStatement() throws SQLException
createStatement 在接口中 ConnectioncreateStatement 在类中 ConnectionAdapterSQLExceptionpublic PreparedStatement prepareStatement(String sql) throws SQLException
prepareStatement 在接口中 ConnectionprepareStatement 在类中 ConnectionAdapterSQLExceptionpublic Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement 在接口中 ConnectioncreateStatement 在类中 ConnectionAdapterSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement 在接口中 ConnectionprepareStatement 在类中 ConnectionAdapterSQLExceptionCopyright © 2023 onecode. All rights reserved.