Package com.jcabi.jdbc
Interface Outcome<T>
-
- Type Parameters:
T- Type of expected result
- All Known Implementing Classes:
ColumnOutcome,ListOutcome,SingleOutcome,StoredProcedureOutcome
public interface Outcome<T>Outcome of ResultSet.The following convenience implementations are provided:
NOT_EMPTYto check that at least one result row is returned.VOIDfor when you wish to disregard the result.UPDATE_COUNTto check the number of updated rows.
- Since:
- 0.12
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceOutcome.Mapping<T>Mapping.static interfaceOutcome.MappingsMappings for different types.
-
Field Summary
Fields Modifier and Type Field Description static Outcome.MappingsDEFAULT_MAPPINGSDefault mappings.static Outcome<Long>LAST_INSERT_IDOutcome that returns last insert ID.static Outcome<Boolean>NOT_EMPTYReturnsTRUEif at least one SQL record found inResultSet.static Outcome<Integer>UPDATE_COUNTOutcome that returns the number of updated rows.static Outcome<Void>VOIDOutcome that does nothing (and always returnsnull).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Thandle(ResultSet rset, Statement stmt)Process the result set and return some value.
-
-
-
Field Detail
-
NOT_EMPTY
static final Outcome<Boolean> NOT_EMPTY
ReturnsTRUEif at least one SQL record found inResultSet.The outcome returns the value of
ResultSet.next()and throwsSQLExceptionin case of a problem.- Since:
- 0.12
-
VOID
static final Outcome<Void> VOID
Outcome that does nothing (and always returnsnull).Useful when you're not interested in the result:
new JdbcSession(source) .sql("INSERT INTO foo (name) VALUES (?)") .set("Jeff Lebowski") .insert(Outcome.VOID);- Since:
- 0.12
-
UPDATE_COUNT
static final Outcome<Integer> UPDATE_COUNT
Outcome that returns the number of updated rows.Use it when you need to determine the number of rows updated:
Integer count = new JdbcSession(source) .sql("UPDATE employee SET salary = 35000 WHERE department = ?") .set("Finance") .update(Outcome.UPDATE_COUNT);- Since:
- 0.12
-
LAST_INSERT_ID
static final Outcome<Long> LAST_INSERT_ID
Outcome that returns last insert ID.Use it when you need to get last insert ID from INSERT:
long id = new JdbcSession(source) .sql("INSERT INTO employee (name) VALUES (?)") .set("Jeffrey") .insert(Outcome.LAST_INSERT_ID);- Since:
- 0.13
-
DEFAULT_MAPPINGS
static final Outcome.Mappings DEFAULT_MAPPINGS
Default mappings.- Since:
- 0.17.6
-
-
Method Detail
-
handle
T handle(ResultSet rset, Statement stmt) throws SQLException
Process the result set and return some value.- Parameters:
rset- The result set to processstmt- The statement used in the run- Returns:
- The result
- Throws:
SQLException- If something goes wrong inside
-
-