jodd.db
Class DbQuery

java.lang.Object
  extended by jodd.db.DbQuery
Direct Known Subclasses:
DbOrmQuery, DbProfiledQuery

public class DbQuery
extends java.lang.Object

Encapsulates Statement and all its operations.

It may be:

  • used in an un-managed way, created directly from connection;
  • managed by DbSession;
  • managed by DbThreadSession i.e. ThreadDbSessionHolder.
  • Query life-cycle states:

  • 1) created: statement == null, initialized == false
  • 2) initialized: statement != null, initialized == true
  • 3) closed: statement == null, initialized == true


    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
    DbQuery(java.sql.Connection conn, java.lang.String sqlString)
              Creates new query,
    DbQuery(DbSession session, java.lang.String sqlString)
              Creates a new query from DbSession.
    DbQuery(java.lang.String sqlString)
              Creates a new query using defualt session provider.
     
    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 clearParameters()
              Clears the current parameter values immediately.
     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()
               
     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 setArray(int index, java.sql.Array value)
               
     void setArray(java.lang.String param, java.sql.Array value)
               
     void setAsciiStream(int index, jodd.io.AsciiInputStream stream)
               
     void setAsciiStream(int index, java.io.InputStream stream, int lenght)
               
     void setAsciiStream(java.lang.String param, jodd.io.AsciiInputStream stream)
               
     void setAsciiStream(java.lang.String param, java.io.InputStream stream, int lenght)
               
     void setBean(java.lang.String beanName, java.lang.Object bean)
              Sets bean parameters from bean.
     void setBigDecimal(int index, java.math.BigDecimal value)
               
     void setBigDecimal(java.lang.String param, java.math.BigDecimal value)
               
     void setBigInteger(int index, java.math.BigInteger value)
               
     void setBigInteger(java.lang.String param, java.math.BigInteger value)
               
     void setBlob(int index, java.sql.Blob value)
               
     void setBlob(java.lang.String param, java.sql.Blob value)
               
     void setBoolean(int index, boolean value)
               
     void setBoolean(int index, java.lang.Boolean value)
               
     void setBoolean(java.lang.String param, boolean value)
               
     void setBoolean(java.lang.String param, java.lang.Boolean value)
               
     void setByte(int index, byte value)
               
     void setByte(int index, java.lang.Number value)
               
     void setByte(java.lang.String param, byte value)
               
     void setByte(java.lang.String param, java.lang.Number value)
               
     void setBytes(int index, byte[] value)
               
     void setBytes(java.lang.String param, byte[] value)
               
     void setCharacterStream(int index, java.io.Reader reader, int lenght)
               
     void setCharacterStream(java.lang.String param, java.io.Reader reader, int lenght)
               
     void setClob(int index, java.sql.Clob value)
               
     void setClob(java.lang.String param, java.sql.Clob value)
               
     void setConcurrencyType(int concurrencyType)
               
     void setDate(int index, java.sql.Date value)
               
     void setDate(java.lang.String param, java.sql.Date value)
               
     void setDebug(boolean debug)
               
     void setDebugMode()
               
     void setDouble(int index, double value)
               
     void setDouble(int index, java.lang.Number value)
               
     void setDouble(java.lang.String param, double value)
               
     void setDouble(java.lang.String param, java.lang.Number value)
               
     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 setFloat(int index, float value)
               
     void setFloat(int index, java.lang.Number value)
               
     void setFloat(java.lang.String param, float value)
               
     void setFloat(java.lang.String param, java.lang.Number value)
               
     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 setInteger(int index, int value)
               
     void setInteger(int index, java.lang.Number value)
               
     void setInteger(java.lang.String param, int value)
               
     void setInteger(java.lang.String param, java.lang.Number value)
               
     void setLong(int index, long value)
               
     void setLong(int index, java.lang.Number value)
               
     void setLong(java.lang.String param, long value)
               
     void setLong(java.lang.String param, java.lang.Number value)
               
     void setMap(java.util.Map parameters)
              Sets properties from the map.
     void setMaxRows(int maxRows)
              Sets the limit for the maximum number of rows that any ResultSet object can contain to the given number.
     void setNull(int index, int type)
               
     void setNull(int index, int type, java.lang.String typeName)
               
     void setNull(java.lang.String param, int type)
               
     void setNull(java.lang.String param, int value, java.lang.String typeName)
               
     void setObject(int index, java.lang.Object value)
               
     void setObject(int index, java.lang.Object value, java.lang.Class<? extends SqlType> sqlTypeClass, int dbSqlType)
              Sets object parameter in an advanced way.
     void setObject(int index, java.lang.Object object, int targetSqlType)
              Sets the value of the designated parameter with the given object.
     void setObject(java.lang.String param, java.lang.Object value)
               
     void setObject(java.lang.String param, java.lang.Object value, java.lang.Class<? extends SqlType> sqlTypeClass, int dbSqlType)
               
     void setObject(java.lang.String param, java.lang.Object object, int targetSqlType)
              Sets the value of the designated parameter with the given object.
     void setObjects(java.lang.Object... objects)
              Sets an array of objects parameters in given order.
     void setObjects(java.lang.String[] names, java.lang.Object[] values)
              Sets sql parameters from two arrays: names and values.
     void setRef(int index, java.sql.Ref value)
               
     void setRef(java.lang.String param, java.sql.Ref value)
               
     void setShort(int index, java.lang.Number value)
               
     void setShort(int index, short value)
               
     void setShort(java.lang.String param, java.lang.Number value)
               
     void setShort(java.lang.String param, short value)
               
     void setString(int index, java.lang.String value)
               
     void setString(java.lang.String param, java.lang.String value)
               
     void setTime(int index, java.sql.Time value)
               
     void setTime(java.lang.String param, java.sql.Time value)
               
     void setTimestamp(int index, java.sql.Timestamp value)
               
     void setTimestamp(java.lang.String param, java.sql.Timestamp value)
               
     void setType(int type)
               
     void setURL(int index, java.net.URL value)
               
     void setURL(java.lang.String param, java.net.URL value)
               
     java.lang.String toString()
               
     void typeForwardOnly()
               
     void typeScrollInsensitive()
               
     void typeScrollSensitive()
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    QUERY_CREATED

    public static final int QUERY_CREATED
    See Also:
    Constant Field Values

    QUERY_INITIALIZED

    public static final int QUERY_INITIALIZED
    See Also:
    Constant Field Values

    QUERY_CLOSED

    public static final int QUERY_CLOSED
    See Also:
    Constant Field Values

    queryState

    protected int queryState

    connection

    protected java.sql.Connection connection

    session

    protected DbSession session

    sqlString

    protected java.lang.String sqlString

    statement

    protected java.sql.Statement statement

    preparedStatement

    protected java.sql.PreparedStatement preparedStatement

    resultSets

    protected java.util.Set<java.sql.ResultSet> resultSets

    query

    protected jodd.db.DbQueryParser query

    forcePreparedStatement

    protected boolean forcePreparedStatement
    If set to true all created statements will be prepared.


    TYPE_FORWARD_ONLY

    public static final int TYPE_FORWARD_ONLY
    See Also:
    ResultSet.TYPE_FORWARD_ONLY, Constant Field Values

    TYPE_SCROLL_SENSITIVE

    public static final int TYPE_SCROLL_SENSITIVE
    See Also:
    ResultSet.TYPE_SCROLL_SENSITIVE, Constant Field Values

    TYPE_SCROLL_INSENSITIVE

    public static final int TYPE_SCROLL_INSENSITIVE
    See Also:
    ResultSet.TYPE_SCROLL_INSENSITIVE, Constant Field Values

    type

    protected int type

    CONCUR_READ_ONLY

    public static final int CONCUR_READ_ONLY
    See Also:
    ResultSet.CONCUR_READ_ONLY, Constant Field Values

    CONCUR_UPDATABLE

    public static final int CONCUR_UPDATABLE
    See Also:
    ResultSet.CONCUR_UPDATABLE, Constant Field Values

    concurrencyType

    protected int concurrencyType

    DEFAULT_HOLDABILITY

    public static final int DEFAULT_HOLDABILITY
    Default holdability. JDBC specification does not specifies default value for holdability.

    See Also:
    Constant Field Values

    CLOSE_CURSORS_AT_COMMIT

    public static final int CLOSE_CURSORS_AT_COMMIT
    See Also:
    ResultSet.CLOSE_CURSORS_AT_COMMIT, Constant Field Values

    HOLD_CURSORS_OVER_COMMIT

    public static final int HOLD_CURSORS_OVER_COMMIT
    See Also:
    ResultSet.HOLD_CURSORS_OVER_COMMIT, Constant Field Values

    holdability

    protected int holdability

    debug

    protected boolean debug

    generatedColumns

    protected java.lang.String[] generatedColumns

    fetchSize

    protected int fetchSize

    maxRows

    protected int maxRows

    totalOpenResultSetCount

    protected static int totalOpenResultSetCount
    Constructor Detail

    DbQuery

    public DbQuery(java.sql.Connection conn,
                   java.lang.String sqlString)
    Creates new query,


    DbQuery

    public DbQuery(DbSession session,
                   java.lang.String sqlString)
    Creates a new query from DbSession.


    DbQuery

    public DbQuery(java.lang.String sqlString)
    Creates a new query using defualt session provider.

    Method Detail

    clearParameters

    public void clearParameters()
    Clears the current parameter values immediately.

    In general, parameter values remain in force for repeated use of a statement. Setting a parameter value automatically clears its previous value. However, in some cases it is useful to immediately release the resources used by the current parameter values; this can be done by calling the method clearParameters. s


    setNull

    public void setNull(int index,
                        int type)

    setNull

    public void setNull(java.lang.String param,
                        int type)

    setNull

    public void setNull(int index,
                        int type,
                        java.lang.String typeName)

    setNull

    public void setNull(java.lang.String param,
                        int value,
                        java.lang.String typeName)

    setInteger

    public void setInteger(int index,
                           int value)

    setInteger

    public void setInteger(java.lang.String param,
                           int value)

    setInteger

    public void setInteger(int index,
                           java.lang.Number value)

    setInteger

    public void setInteger(java.lang.String param,
                           java.lang.Number value)

    setBoolean

    public void setBoolean(int index,
                           boolean value)

    setBoolean

    public void setBoolean(java.lang.String param,
                           boolean value)

    setBoolean

    public void setBoolean(int index,
                           java.lang.Boolean value)

    setBoolean

    public void setBoolean(java.lang.String param,
                           java.lang.Boolean value)

    setLong

    public void setLong(int index,
                        long value)

    setLong

    public void setLong(java.lang.String param,
                        long value)

    setLong

    public void setLong(int index,
                        java.lang.Number value)

    setLong

    public void setLong(java.lang.String param,
                        java.lang.Number value)

    setByte

    public void setByte(int index,
                        byte value)

    setByte

    public void setByte(java.lang.String param,
                        byte value)

    setByte

    public void setByte(int index,
                        java.lang.Number value)

    setByte

    public void setByte(java.lang.String param,
                        java.lang.Number value)

    setBytes

    public void setBytes(int index,
                         byte[] value)

    setBytes

    public void setBytes(java.lang.String param,
                         byte[] value)

    setDouble

    public void setDouble(int index,
                          double value)

    setDouble

    public void setDouble(java.lang.String param,
                          double value)

    setDouble

    public void setDouble(int index,
                          java.lang.Number value)

    setDouble

    public void setDouble(java.lang.String param,
                          java.lang.Number value)

    setFloat

    public void setFloat(int index,
                         float value)

    setFloat

    public void setFloat(java.lang.String param,
                         float value)

    setFloat

    public void setFloat(int index,
                         java.lang.Number value)

    setFloat

    public void setFloat(java.lang.String param,
                         java.lang.Number value)

    setShort

    public void setShort(int index,
                         short value)

    setShort

    public void setShort(java.lang.String param,
                         short value)

    setShort

    public void setShort(int index,
                         java.lang.Number value)

    setShort

    public void setShort(java.lang.String param,
                         java.lang.Number value)

    setString

    public void setString(int index,
                          java.lang.String value)

    setString

    public void setString(java.lang.String param,
                          java.lang.String value)

    setDate

    public void setDate(int index,
                        java.sql.Date value)

    setDate

    public void setDate(java.lang.String param,
                        java.sql.Date value)

    setTime

    public void setTime(int index,
                        java.sql.Time value)

    setTime

    public void setTime(java.lang.String param,
                        java.sql.Time value)

    setTimestamp

    public void setTimestamp(int index,
                             java.sql.Timestamp value)

    setTimestamp

    public void setTimestamp(java.lang.String param,
                             java.sql.Timestamp value)

    setBigDecimal

    public void setBigDecimal(int index,
                              java.math.BigDecimal value)

    setBigDecimal

    public void setBigDecimal(java.lang.String param,
                              java.math.BigDecimal value)

    setBigInteger

    public void setBigInteger(int index,
                              java.math.BigInteger value)

    setBigInteger

    public void setBigInteger(java.lang.String param,
                              java.math.BigInteger value)

    setURL

    public void setURL(int index,
                       java.net.URL value)

    setURL

    public void setURL(java.lang.String param,
                       java.net.URL value)

    setBlob

    public void setBlob(int index,
                        java.sql.Blob value)

    setBlob

    public void setBlob(java.lang.String param,
                        java.sql.Blob value)

    setClob

    public void setClob(int index,
                        java.sql.Clob value)

    setClob

    public void setClob(java.lang.String param,
                        java.sql.Clob value)

    setArray

    public void setArray(int index,
                         java.sql.Array value)

    setArray

    public void setArray(java.lang.String param,
                         java.sql.Array value)

    setRef

    public void setRef(int index,
                       java.sql.Ref value)

    setRef

    public void setRef(java.lang.String param,
                       java.sql.Ref value)

    setAsciiStream

    public void setAsciiStream(int index,
                               jodd.io.AsciiInputStream stream)

    setAsciiStream

    public void setAsciiStream(java.lang.String param,
                               jodd.io.AsciiInputStream stream)

    setAsciiStream

    public void setAsciiStream(int index,
                               java.io.InputStream stream,
                               int lenght)

    setAsciiStream

    public void setAsciiStream(java.lang.String param,
                               java.io.InputStream stream,
                               int lenght)

    setCharacterStream

    public void setCharacterStream(int index,
                                   java.io.Reader reader,
                                   int lenght)

    setCharacterStream

    public void setCharacterStream(java.lang.String param,
                                   java.io.Reader reader,
                                   int lenght)

    setBean

    public void setBean(java.lang.String beanName,
                        java.lang.Object bean)
    Sets bean parameters from bean. Non-existing bean properties are ignored.


    setMap

    public void setMap(java.util.Map parameters)
    Sets properties from the map.


    setObject

    public void setObject(int index,
                          java.lang.Object object,
                          int targetSqlType)
    Sets the value of the designated parameter with the given object. This method is like the method setObject above, except that it assumes a scale of zero.


    setObject

    public void setObject(java.lang.String param,
                          java.lang.Object object,
                          int targetSqlType)
    Sets the value of the designated parameter with the given object. This method is like the method setObject above, except that it assumes a scale of zero.


    setObject

    public void setObject(int index,
                          java.lang.Object value)
    See Also:
    setObject(String, Object, Class, int)

    setObject

    public void setObject(int index,
                          java.lang.Object value,
                          java.lang.Class<? extends SqlType> sqlTypeClass,
                          int dbSqlType)
    Sets object parameter in an advanced way.

    First, it checks if object is null and invokes setNull if so. If object is not null, it tries to resolve sql type (by looking up or using provided class) and use it for setting data. If sql type is not found, default setObject is invoked.


    setObject

    public void setObject(java.lang.String param,
                          java.lang.Object value)
    See Also:
    setObject(String, Object, Class, int)

    setObject

    public void setObject(java.lang.String param,
                          java.lang.Object value,
                          java.lang.Class<? extends SqlType> sqlTypeClass,
                          int dbSqlType)
    See Also:
    setObject(String, Object, Class, int)

    setObjects

    public void setObjects(java.lang.Object... objects)
    Sets an array of objects parameters in given order.


    setObjects

    public void setObjects(java.lang.String[] names,
                           java.lang.Object[] values)
    Sets sql parameters from two arrays: names and values.


    getQueryState

    public int getQueryState()
    Returns query state.


    checkNotClosed

    protected void checkNotClosed()
    Checks if query is not closed and throws an exception if it is.


    checkCreated

    protected void checkCreated()
    Checks if query is created (and not yet initialized or closed) and throws an exception if it is not.


    checkInitialized

    protected void checkInitialized()
    Checks if query is initialized and throws an exception if it is not.


    isClosed

    public boolean isClosed()
    Returns true if query is closed.


    isActive

    public boolean isActive()
    Returns true if query is active: created and possibly initialized. Opened query may be not initialized.


    isInitialized

    public boolean isInitialized()
    Returns true if query is initialized. Initialized query is the one that has created JDBC statements.


    saveResultSet

    protected void saveResultSet(java.sql.ResultSet rs)
    Stores result set.


    forcePreparedStatement

    public void forcePreparedStatement()
    Forces creation of prepared statements.


    init

    public final void init()
    Initializes the query if not already initialized. Usually, user doesn't have to invoke it at all, since it will be called before all methods that deals directly with JDBC statement. Throws an exception if called on closed query.


    initializeJdbc

    protected void initializeJdbc()
    Performs JDBC initialization of the query. Obtains connection, parses the SQL query string and creates statements. Initialization is performed only once, when switching to initialized state.


    prepareQuery

    protected void prepareQuery()
    Prepares the query just after the initialization. Query is fully set and ready.


    closeAllResultSets

    public void closeAllResultSets()
    Closes all result sets created by this query. Query remains active.


    closeQuery

    protected java.util.List<java.sql.SQLException> closeQuery()
    Closes all assigned result sets and then closes the query. Query becomes closed.


    close

    public void close()
    Closes the query and all created results sets and detaches itself from the session.


    closeResultSet

    public 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. Query remains active.


    getType

    public int getType()

    setType

    public void setType(int type)

    typeForwardOnly

    public void typeForwardOnly()

    typeScrollSensitive

    public void typeScrollSensitive()

    typeScrollInsensitive

    public void typeScrollInsensitive()

    getConcurrencyType

    public int getConcurrencyType()

    setConcurrencyType

    public void setConcurrencyType(int concurrencyType)

    concurReadOnly

    public void concurReadOnly()

    concurUpdatable

    public void concurUpdatable()

    getHoldability

    public int getHoldability()

    setHoldability

    public void setHoldability(int holdability)

    holdCursorsOverCommit

    public void holdCursorsOverCommit()

    closeCursorsAtCommit

    public void closeCursorsAtCommit()

    isInDebugMode

    public boolean isInDebugMode()

    setDebug

    public void setDebug(boolean debug)

    setDebugMode

    public void setDebugMode()

    getGeneratedColumnNames

    public java.lang.String[] getGeneratedColumnNames()
    Returns generated column names.


    setGeneratedColumns

    public void setGeneratedColumns(java.lang.String... columns)
    Specifies columns which values will be generated by database.


    setGeneratedKey

    public void setGeneratedKey()
    Specifies that database will generate some columns values, usually the single id.


    resetGeneratedColumns

    public void resetGeneratedColumns()
    Resets creating generated columns.


    getFetchSize

    public int getFetchSize()

    setFetchSize

    public 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. The number of rows specified affects only result sets created using this statement. If the value specified is zero, then the hint is ignored. The default value is zero.

    See Also:
    Statement.setFetchSize(int)

    getMaxRows

    public int getMaxRows()

    setMaxRows

    public void setMaxRows(int maxRows)
    Sets the limit for the maximum number of rows that any ResultSet object can contain to the given number. If the limit is exceeded, the excess rows are silently dropped. Zero means there is no limit.

    See Also:
    Statement.setMaxRows(int)

    execute

    public java.sql.ResultSet execute()
    Executes the query. If this method is invoked at least once, the query or all created ResultSets must be explicitly closed at the end of query usage. This can be done explicitly by calling DbQueryBase.closeResultSet(ResultSet) оr implicitly, during DbQueryBase.close().

    See Also:
    Statement.execute(String)

    executeUpdate

    public int executeUpdate()
    Executes UPDATE, INSERT or DELETE queries. Query is not closed afterwards.

    See Also:
    Statement.executeUpdate(String)

    executeUpdateAndClose

    public int executeUpdateAndClose()
    Executes UPDATE, INSERT or DELETE queries and closes query afterwards.

    See Also:
    Statement.executeUpdate(String)

    executeUpdate

    protected int executeUpdate(boolean closeQuery)
    Executes UPDATE, INSERT or DELETE queries and optionally closes the query.

    See Also:
    Statement.executeUpdate(String)

    executeCount

    public long executeCount()
    Special execute() for 'select count(*)' queries. Query is not closed after the execution. It doesn't check if query is really a count query. If result set returns zero rows, (what is very unlikely), it returns -1.


    executeCountAndClose

    public long executeCountAndClose()
    Executes count queries and closes afterwards.


    executeCount

    protected long executeCount(boolean close)
    Executes count queries and optionally closes query afterwards.


    getGeneratedColumns

    public java.sql.ResultSet getGeneratedColumns()
    Returns generated columns.


    getGeneratedKey

    public long getGeneratedKey()
    Returns generated key i.e. first genereted column as long.


    getQueryString

    public java.lang.String getQueryString()
    Returns query SQL string. For prepared statements, returned sql string with quick-and-dirty replaced values.


    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object
    See Also:
    getQueryString()

    getTotalOpenResultSetCount

    public static int getTotalOpenResultSetCount()
    Returns total number of open result sets.

    See Also:
    getOpenResultSetCount()

    getOpenResultSetCount

    public int getOpenResultSetCount()
    Returns number of created result sets that are still not explicitly closed.

    See Also:
    getTotalOpenResultSetCount()


    Copyright © 2003-2011 Jodd Team