|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjodd.db.DbQuery
jodd.db.DbProfiledQuery
public class DbProfiledQuery
Profiled DbQuery measures query execution time. May be used for debugging purposes.
| Field Summary | |
|---|---|
static int |
CLOSE_CURSORS_AT_COMMIT
|
static int |
CONCUR_READ_ONLY
|
static int |
CONCUR_UPDATABLE
|
protected int |
concurrencyType
|
protected java.sql.Connection |
connection
|
protected boolean |
debug
|
static int |
DEFAULT_HOLDABILITY
Default holdability. |
protected int |
fetchSize
|
protected boolean |
forcePreparedStatement
If set to true all created statements will be prepared. |
protected java.lang.String[] |
generatedColumns
|
static int |
HOLD_CURSORS_OVER_COMMIT
|
protected int |
holdability
|
protected int |
maxRows
|
protected java.sql.PreparedStatement |
preparedStatement
|
protected jodd.db.DbQueryParser |
query
|
static int |
QUERY_CLOSED
|
static int |
QUERY_CREATED
|
static int |
QUERY_INITIALIZED
|
protected int |
queryState
|
protected java.util.Set<java.sql.ResultSet> |
resultSets
|
protected DbSession |
session
|
protected java.lang.String |
sqlString
|
protected java.sql.Statement |
statement
|
protected static int |
totalOpenResultSetCount
|
protected int |
type
|
static int |
TYPE_FORWARD_ONLY
|
static int |
TYPE_SCROLL_INSENSITIVE
|
static int |
TYPE_SCROLL_SENSITIVE
|
| Constructor Summary | |
|---|---|
DbProfiledQuery(java.sql.Connection conn,
java.lang.String sql)
|
|
DbProfiledQuery(DbSession session,
java.lang.String sqlString)
|
|
DbProfiledQuery(java.lang.String sqlString)
|
|
| Method Summary | |
|---|---|
protected void |
checkCreated()
Checks if query is created (and not yet initialized or closed) and throws an exception if it is not. |
protected void |
checkInitialized()
Checks if query is initialized and throws an exception if it is not. |
protected void |
checkNotClosed()
Checks if query is not closed and throws an exception if it is. |
void |
close()
Closes the query and all created results sets and detaches itself from the session. |
void |
closeAllResultSets()
Closes all result sets created by this query. |
void |
closeCursorsAtCommit()
|
protected java.util.List<java.sql.SQLException> |
closeQuery()
Closes all assigned result sets and then closes the query. |
void |
closeResultSet(java.sql.ResultSet rs)
Closes single result set that was created by this query, It is not necessary to close result sets explicitly, since DbQueryBase.close() method closes all created result sets. |
void |
concurReadOnly()
|
void |
concurUpdatable()
|
java.sql.ResultSet |
execute()
Executes the query. |
long |
executeCount()
Special execute() for 'select count(*)' queries. |
protected long |
executeCount(boolean close)
Executes count queries and optionally closes query afterwards. |
long |
executeCountAndClose()
Executes count queries and closes afterwards. |
int |
executeUpdate()
Executes UPDATE, INSERT or DELETE queries. |
protected int |
executeUpdate(boolean closeQuery)
Executes UPDATE, INSERT or DELETE queries and optionally closes the query. |
int |
executeUpdateAndClose()
Executes UPDATE, INSERT or DELETE queries and closes query afterwards. |
void |
forcePreparedStatement()
Forces creation of prepared statements. |
int |
getConcurrencyType()
|
long |
getExecutionElapsedTime()
Returns query execution elapsed time in ms. |
int |
getFetchSize()
|
java.lang.String[] |
getGeneratedColumnNames()
Returns generated column names. |
java.sql.ResultSet |
getGeneratedColumns()
Returns generated columns. |
long |
getGeneratedKey()
Returns generated key i.e. first genereted column as long. |
int |
getHoldability()
|
int |
getMaxRows()
|
int |
getOpenResultSetCount()
Returns number of created result sets that are still not explicitly closed. |
int |
getQueryState()
Returns query state. |
java.lang.String |
getQueryString()
Returns query SQL string. |
static int |
getTotalOpenResultSetCount()
Returns total number of open result sets. |
int |
getType()
|
void |
holdCursorsOverCommit()
|
void |
init()
Initializes the query if not already initialized. |
protected void |
initializeJdbc()
Performs JDBC initialization of the query. |
boolean |
isActive()
Returns true if query is active: created and possibly initialized. |
boolean |
isClosed()
Returns true if query is closed. |
boolean |
isInDebugMode()
|
boolean |
isInitialized()
Returns true if query is initialized. |
protected void |
prepareQuery()
Prepares the query just after the initialization. |
void |
resetGeneratedColumns()
Resets creating generated columns. |
protected void |
saveResultSet(java.sql.ResultSet rs)
Stores result set. |
void |
setConcurrencyType(int concurrencyType)
|
void |
setDebug(boolean debug)
|
void |
setDebugMode()
|
void |
setFetchSize(int rows)
Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. |
void |
setGeneratedColumns(java.lang.String... columns)
Specifies columns which values will be generated by database. |
void |
setGeneratedKey()
Specifies that database will generate some columns values, usually the single id. |
void |
setHoldability(int holdability)
|
void |
setMaxRows(int maxRows)
Sets the limit for the maximum number of rows that any ResultSet object can contain to the given number. |
void |
setType(int type)
|
java.lang.String |
toString()
|
void |
typeForwardOnly()
|
void |
typeScrollInsensitive()
|
void |
typeScrollSensitive()
|
| Methods inherited from class jodd.db.DbQuery |
|---|
clearParameters, setArray, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setAsciiStream, setBean, setBigDecimal, setBigDecimal, setBigInteger, setBigInteger, setBlob, setBlob, setBoolean, setBoolean, setBoolean, setBoolean, setByte, setByte, setByte, setByte, setBytes, setBytes, setCharacterStream, setCharacterStream, setClob, setClob, setDate, setDate, setDouble, setDouble, setDouble, setDouble, setFloat, setFloat, setFloat, setFloat, setInteger, setInteger, setInteger, setInteger, setLong, setLong, setLong, setLong, setMap, setNull, setNull, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setObject, setObjects, setObjects, setRef, setRef, setShort, setShort, setShort, setShort, setString, setString, setTime, setTime, setTimestamp, setTimestamp, setURL, setURL |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int QUERY_CREATED
public static final int QUERY_INITIALIZED
public static final int QUERY_CLOSED
protected int queryState
protected java.sql.Connection connection
protected DbSession session
protected java.lang.String sqlString
protected java.sql.Statement statement
protected java.sql.PreparedStatement preparedStatement
protected java.util.Set<java.sql.ResultSet> resultSets
protected jodd.db.DbQueryParser query
protected boolean forcePreparedStatement
true all created statements will be prepared.
public static final int TYPE_FORWARD_ONLY
ResultSet.TYPE_FORWARD_ONLY,
Constant Field Valuespublic static final int TYPE_SCROLL_SENSITIVE
ResultSet.TYPE_SCROLL_SENSITIVE,
Constant Field Valuespublic static final int TYPE_SCROLL_INSENSITIVE
ResultSet.TYPE_SCROLL_INSENSITIVE,
Constant Field Valuesprotected int type
public static final int CONCUR_READ_ONLY
ResultSet.CONCUR_READ_ONLY,
Constant Field Valuespublic static final int CONCUR_UPDATABLE
ResultSet.CONCUR_UPDATABLE,
Constant Field Valuesprotected int concurrencyType
public static final int DEFAULT_HOLDABILITY
public static final int CLOSE_CURSORS_AT_COMMIT
ResultSet.CLOSE_CURSORS_AT_COMMIT,
Constant Field Valuespublic static final int HOLD_CURSORS_OVER_COMMIT
ResultSet.HOLD_CURSORS_OVER_COMMIT,
Constant Field Valuesprotected int holdability
protected boolean debug
protected java.lang.String[] generatedColumns
protected int fetchSize
protected int maxRows
protected static int totalOpenResultSetCount
| Constructor Detail |
|---|
public DbProfiledQuery(java.sql.Connection conn,
java.lang.String sql)
public DbProfiledQuery(DbSession session,
java.lang.String sqlString)
public DbProfiledQuery(java.lang.String sqlString)
| Method Detail |
|---|
public int executeUpdate()
Statement.executeUpdate(String)public java.sql.ResultSet execute()
DbQueryBase.closeResultSet(ResultSet)
оr implicitly, during DbQueryBase.close().
Statement.execute(String)public long executeCount()
-1.
public long getExecutionElapsedTime()
-1 if query is still not executed.
public java.lang.String getQueryString()
public int getQueryState()
protected void checkNotClosed()
protected void checkCreated()
protected void checkInitialized()
public boolean isClosed()
true if query is closed.
public boolean isActive()
true if query is active: created and possibly initialized.
Opened query may be not initialized.
public boolean isInitialized()
true if query is initialized. Initialized query is the one that has
created JDBC statements.
protected void saveResultSet(java.sql.ResultSet rs)
public void forcePreparedStatement()
public final void init()
protected void initializeJdbc()
protected void prepareQuery()
public void closeAllResultSets()
protected java.util.List<java.sql.SQLException> closeQuery()
public void close()
public void closeResultSet(java.sql.ResultSet rs)
DbQueryBase.close() method closes all created result sets.
Query remains active.
public int getType()
public void setType(int type)
public void typeForwardOnly()
public void typeScrollSensitive()
public void typeScrollInsensitive()
public int getConcurrencyType()
public void setConcurrencyType(int concurrencyType)
public void concurReadOnly()
public void concurUpdatable()
public int getHoldability()
public void setHoldability(int holdability)
public void holdCursorsOverCommit()
public void closeCursorsAtCommit()
public boolean isInDebugMode()
public void setDebug(boolean debug)
public void setDebugMode()
public java.lang.String[] getGeneratedColumnNames()
public void setGeneratedColumns(java.lang.String... columns)
public void setGeneratedKey()
public void resetGeneratedColumns()
public int getFetchSize()
public void setFetchSize(int rows)
Statement.setFetchSize(int)public int getMaxRows()
public void setMaxRows(int maxRows)
Statement.setMaxRows(int)public int executeUpdateAndClose()
Statement.executeUpdate(String)protected int executeUpdate(boolean closeQuery)
Statement.executeUpdate(String)public long executeCountAndClose()
protected long executeCount(boolean close)
public java.sql.ResultSet getGeneratedColumns()
public long getGeneratedKey()
long.
public java.lang.String toString()
toString in class java.lang.ObjectgetQueryString()public static int getTotalOpenResultSetCount()
getOpenResultSetCount()public int getOpenResultSetCount()
getTotalOpenResultSetCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||