Package io.github.pigaut.sql
Interface DatabaseStatement
- All Known Implementing Classes:
SimpleDatabaseStatement
public interface DatabaseStatement
-
Method Summary
Modifier and TypeMethodDescriptionaddBatch()Adds a batch operation to the statement.addOption(StatementOption option)Adds an option to the statement.voidRemoves all options for this statement.booleanexecute()Executes the SQL statement.int[]Executes a batch of SQL statements.long[]Executes a large batch of SQL statements.longExecutes a large update SQL statement.voidexecuteQuery(QueryReader reader)Executes a query SQL statement and processes the results with a QueryReader.intExecutes an update SQL statement.voidfetchAllRows(QueryReader reader)Fetches all rows from the result set.voidfetchRow(QueryReader reader)Fetches the first row from the result set.Replaces a placeholder in the SQL statement with a specific value.Sets a parameter in the statement as NULL.withParameter(boolean value)Sets a parameter in the statement as a boolean value.withParameter(byte value)Sets a parameter in the statement as a byte value.withParameter(double value)Sets a parameter in the statement as a double value.withParameter(float value)Sets a parameter in the statement as a float value.withParameter(int value)Sets a parameter in the statement as an integer value.withParameter(long value)Sets a parameter in the statement as a long value.withParameter(short value)Sets a parameter in the statement as a short value.withParameter(InputStream inputStream)withParameter(Object object)Sets a parameter in the statement with a specified object.withParameter(Object object, int sqlType)Sets a parameter in the statement with a specified object and SQL type.withParameter(String value)Sets a parameter in the statement as a string value.
-
Method Details
-
replace
Replaces a placeholder in the SQL statement with a specific value.- Parameters:
placeholder- the placeholder to replacevalue- the value to replace with- Returns:
- the updated SimpleDatabaseStatement object
-
addOption
Adds an option to the statement.- Parameters:
option- the statement option to add- Returns:
- the updated SimpleDatabaseStatement object
-
clearOptions
void clearOptions()Removes all options for this statement. -
addBatch
DatabaseStatement addBatch()Adds a batch operation to the statement.- Returns:
- the updated SimpleDatabaseStatement object
-
withNullParameter
DatabaseStatement withNullParameter()Sets a parameter in the statement as NULL.- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement with a specified object.- Parameters:
object- the object to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement with a specified object and SQL type.- Parameters:
object- the object to set as the parametersqlType- the SQL type of the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a boolean value.- Parameters:
value- the boolean value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a string value.- Parameters:
value- the string value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as an integer value.- Parameters:
value- the integer value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a long value.- Parameters:
value- the long value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a short value.- Parameters:
value- the short value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a byte value.- Parameters:
value- the byte value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a float value.- Parameters:
value- the float value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
Sets a parameter in the statement as a double value.- Parameters:
value- the double value to set as the parameter- Returns:
- the updated SimpleDatabaseStatement object
-
withParameter
-
execute
boolean execute()Executes the SQL statement.- Returns:
- true if the execution was successful, false otherwise
-
executeUpdate
int executeUpdate()Executes an update SQL statement.- Returns:
- the number of rows affected
-
executeLargeUpdate
long executeLargeUpdate()Executes a large update SQL statement.- Returns:
- the number of rows affected
-
executeQuery
Executes a query SQL statement and processes the results with a QueryReader.- Parameters:
reader- the QueryReader to process the query results
-
fetchRow
Fetches the first row from the result set.- Parameters:
reader- the QueryReader to process the first row
-
fetchAllRows
Fetches all rows from the result set.- Parameters:
reader- the QueryReader to process all rows
-
executeBatch
int[] executeBatch()Executes a batch of SQL statements.- Returns:
- an array of update counts indicating the success of each command
-
executeLargeBatch
long[] executeLargeBatch()Executes a large batch of SQL statements.- Returns:
- an array of update counts indicating the success of each command
-