public final class CSQL extends SResultSet implements ResultsLoader
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEBUG_SHOW_STACK
show the stack trace
|
static int |
DEFAULT_QUERY_TIMEOUT_SECONDS
the default number of seconds before timing out
|
static org.apache.commons.logging.Log |
LOGGER_TIMINGS_SQL
the SQL logger
|
static java.lang.String |
PROPERTY_DEFAULT_QUERY_TIMEOUT_SECONDS
control the default query timeout
|
static java.lang.String |
PROPERTY_LOG_SLOW_STACK_TRACE_TIME
control the time we will log the stack traces of slow requests
|
ALLOW_OVERFLOW, columnKeys, columns, currentData, rowOffset, rowPage| Modifier and Type | Method and Description |
|---|---|
CSQL |
addBatch(java.lang.String theSql)
Batch batchStatement
|
CSQL |
addPreparedStatement(java.lang.String statement,
java.lang.Object... args)
add prepared statement
|
static void |
addThreadID(java.lang.String threadID)
add additional thread IDs
|
void |
beginTransaction()
Starts a transaction.
|
protected void |
clear() |
static void |
clearThreadIDs()
clear the Thread IDs.
|
void |
commit()
Ends a transaction.
|
CSQL |
disableErrorLogging()
Disable error level logging ( warning only).
|
CSQL |
enableErrorLogging()
Enable error level logging
|
java.lang.String |
encodeTableData(boolean header_fg)
Produces a tab separated data string.
|
java.lang.String |
encodeTableData(boolean header_fg,
int whichRow,
java.util.List restrictCols)
With addition option of a row ( -1 for all rows) and only some columns
|
void |
execute(java.lang.String inSql) |
int[] |
executeBatch()
Execute batch batchStatement
|
CSQL |
findOne(java.lang.String theSelect) |
int |
getColumnType(int c)
Returns the name of the column at index.
|
DataBase |
getDataBase() |
java.sql.SQLWarning |
getFirstWarning(java.sql.Statement stmt) |
static long |
getHitCount()
The hit count
|
static long |
getHitRowCount()
The hit ROW count
|
static long |
getLargeHitCount()
The hit count
|
int |
getRowCount() |
java.lang.String |
getSQL() |
java.lang.String |
getSQLTypeDesc() |
java.lang.String |
getWarningText() |
boolean |
hasColumn(java.lang.String key) |
boolean |
hasMoreResults() |
boolean |
hasOutput()
Returns true if the batchStatement was a select type of batchStatement
|
boolean |
hasWarnings() |
static long |
incrementHitCount()
Increment hit count
|
static long |
incrementLargeHitCount()
Increment hit count
|
boolean |
isStateless()
are we stateless ?
|
int |
loadResults(java.sql.Statement stmt) |
void |
lockConnection()
Lock the database connection
|
CSQL |
nextResults() |
CSQL |
perform(java.lang.String inSql)
performs the SQL batchStatement passed.
|
static void |
recordTime(java.lang.Object inObj,
Lap lap,
java.sql.Connection conn,
java.lang.Throwable e,
int rows,
DataBase dataBase)
Record the SQL time
|
static java.util.concurrent.atomic.AtomicLong |
registerThreadHitsCounter(java.util.concurrent.atomic.AtomicLong counter)
register the hits counter for this thread
|
static java.util.concurrent.atomic.AtomicLong |
registerThreadLargeHitsCounter(java.util.concurrent.atomic.AtomicLong counter)
register the hits counter for this thread
|
static java.util.concurrent.atomic.AtomicLong |
registerThreadTimeOnDB(java.util.concurrent.atomic.AtomicLong timeOnDB)
register the time on the database for this thread
|
void |
rollback()
Rolls back the current transaction.
|
CSQL |
setLoader(ResultsLoader loader) |
CSQL |
setMaxRow(int maxRow) |
CSQL |
setQueryTimeOutSeconds(int seconds)
Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.
|
CSQL |
setReadOnly(boolean readonly)
Force the statement to be read only
|
static long |
simulateSlowQuery(long delayMS)
Slow ALL queries from this thread down by the delay milliseconds.
|
void |
unlockConnection()
Unlock the database connection.
|
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, decodeTableData, deleteRow, fetchRow, findColumn, findColumnData, findColumnData, first, formatOutput, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getColumnCount, getColumnDisplaySize, getColumnName, getColumns, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getMetaData, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isNull, isNull, isWrapperFor, last, load, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rewind, rowDeleted, rowInserted, rowUpdated, setCurrentRow, setFetchDirection, setFetchSize, sqlColumnNr, toString, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, validToGet, wasNullpublic static final org.apache.commons.logging.Log LOGGER_TIMINGS_SQL
public static final java.lang.String DEBUG_SHOW_STACK
public static final java.lang.String PROPERTY_LOG_SLOW_STACK_TRACE_TIME
public static final java.lang.String PROPERTY_DEFAULT_QUERY_TIMEOUT_SECONDS
public static final int DEFAULT_QUERY_TIMEOUT_SECONDS
public CSQL(@Nonnull
DataBase db)
db - the databasepublic static long simulateSlowQuery(@Nonnegative
long delayMS)
delayMS - 0 or less means no delay.@Nonnull public CSQL disableErrorLogging()
@Nonnull public CSQL enableErrorLogging()
@Nonnull public CSQL setReadOnly(boolean readonly)
readonly - true if this query should be readonly.public static void addThreadID(@Nonnull
java.lang.String threadID)
threadID - the thread idpublic static void clearThreadIDs()
@Nonnull
public static java.util.concurrent.atomic.AtomicLong registerThreadHitsCounter(@Nonnull
java.util.concurrent.atomic.AtomicLong counter)
counter - the hits counter@Nonnull
public static java.util.concurrent.atomic.AtomicLong registerThreadLargeHitsCounter(@Nonnull
java.util.concurrent.atomic.AtomicLong counter)
counter - the hits counter@Nonnull
public static java.util.concurrent.atomic.AtomicLong registerThreadTimeOnDB(@Nonnull
java.util.concurrent.atomic.AtomicLong timeOnDB)
timeOnDB - the time on the database@Nonnull public CSQL setLoader(@Nonnull ResultsLoader loader)
loader - the loaderpublic void lockConnection()
throws java.sql.SQLException
java.sql.SQLException - a serious problempublic void unlockConnection()
@CheckReturnValue @Nonnull public DataBase getDataBase()
@CheckReturnValue
public boolean isStateless()
throws java.lang.Exception
java.lang.Exception - a database error occurredpublic void beginTransaction()
throws java.sql.SQLException
java.sql.SQLException - a serious problempublic void commit()
throws java.sql.SQLException
java.sql.SQLException - a serious problempublic void rollback()
@CheckReturnValue @Nonnegative public int getRowCount()
@CheckReturnValue @Nonnull public java.lang.String getSQLTypeDesc()
@CheckReturnValue
public int getColumnType(@Nonnegative
int c)
SResultSetgetColumnType in class SResultSetc - the column@CheckReturnValue
public boolean hasColumn(@Nonnull
java.lang.String key)
key - the column@Nonnull public CSQL setQueryTimeOutSeconds(@Nonnegative int seconds)
seconds - the new query timeout limit in seconds; ZERO means there is no limitpublic void execute(@Syntax(value="SQL") @Nonnull
java.lang.String inSql)
throws java.sql.SQLException
inSql - the SQLjava.sql.SQLException - a serious problem@Nonnull public CSQL addBatch(@Syntax(value="SQL") @Nonnull java.lang.String theSql) throws java.sql.SQLException
theSql - sql batchStatementjava.sql.SQLException - a database problem@Nonnull public CSQL addPreparedStatement(@Syntax(value="SQL") @Nonnull java.lang.String statement, java.lang.Object... args) throws java.sql.SQLException
statement - SQL batchStatementargs - the arguments to use.java.sql.SQLException - a database problem@Nonnull
public int[] executeBatch()
throws java.sql.SQLException
java.sql.SQLException - a database problempublic static void recordTime(@Nullable
java.lang.Object inObj,
@Nonnull
Lap lap,
@Nullable
java.sql.Connection conn,
@Nullable
java.lang.Throwable e,
int rows,
@Nonnull
DataBase dataBase)
inObj - The SQLlap - When did we start ?conn - The connectione - the exceptionrows - the number of rowsdataBase - the current database.@CheckReturnValue public boolean hasWarnings()
@CheckReturnValue
@Nullable
public java.sql.SQLWarning getFirstWarning(@Nonnull
java.sql.Statement stmt)
throws java.lang.Exception
stmt - the batchStatementjava.lang.Exception - a serious problem@CheckReturnValue @Nonnull public java.lang.String getWarningText()
public int loadResults(@Nonnull
java.sql.Statement stmt)
throws java.lang.Exception
loadResults in interface ResultsLoaderstmt - the batchStatementjava.lang.Exception - a serious problem@CheckReturnValue @Nullable public CSQL nextResults()
@CheckReturnValue @Nonnull public boolean hasMoreResults()
@CheckReturnValue @Nonnull @Syntax(value="SQL") public java.lang.String getSQL()
@Nonnull public CSQL perform(@Syntax(value="SQL") @Nonnull java.lang.String inSql) throws java.sql.SQLException
inSql - the SQLjava.sql.SQLException - a serious problem@Nonnull public CSQL findOne(@Syntax(value="SQL") @Nonnull java.lang.String theSelect) throws java.sql.SQLException, NotFoundException
theSelect - the selectjava.sql.SQLException - a serious problemNotFoundException - not found@Nonnull public CSQL setMaxRow(int maxRow)
maxRow - the max number of rows.@CheckReturnValue public boolean hasOutput()
@CheckReturnValue
@Nullable
public java.lang.String encodeTableData(boolean header_fg)
throws java.sql.SQLException
header_fg - include headerjava.sql.SQLException - a serious problem@Nonnegative public static long incrementHitCount()
@CheckReturnValue @Nonnegative public static long getHitCount()
@CheckReturnValue @Nonnegative public static long getHitRowCount()
@Nonnegative public static long incrementLargeHitCount()
@CheckReturnValue @Nonnegative public static long getLargeHitCount()
@CheckReturnValue
@Nullable
public java.lang.String encodeTableData(boolean header_fg,
int whichRow,
java.util.List restrictCols)
throws java.sql.SQLException
header_fg - include headerwhichRow - which rowrestrictCols - the columnsjava.sql.SQLException - a serious problemprotected void clear()
clear in class SResultSetstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.