Class SimpleDatabaseStatement

java.lang.Object
io.github.pigaut.sql.database.statement.SimpleDatabaseStatement
All Implemented Interfaces:
DatabaseStatement

public class SimpleDatabaseStatement extends Object implements DatabaseStatement
  • Constructor Details

    • SimpleDatabaseStatement

      public SimpleDatabaseStatement(Database database, String sql)
  • Method Details

    • replace

      public DatabaseStatement replace(String placeholder, String value)
      Description copied from interface: DatabaseStatement
      Replaces a placeholder in the SQL statement with a specific value.
      Specified by:
      replace in interface DatabaseStatement
      Parameters:
      placeholder - the placeholder to replace
      value - the value to replace with
      Returns:
      the updated SimpleDatabaseStatement object
    • addOption

      public DatabaseStatement addOption(StatementOption option)
      Description copied from interface: DatabaseStatement
      Adds an option to the statement.
      Specified by:
      addOption in interface DatabaseStatement
      Parameters:
      option - the statement option to add
      Returns:
      the updated SimpleDatabaseStatement object
    • clearOptions

      public void clearOptions()
      Description copied from interface: DatabaseStatement
      Removes all options for this statement.
      Specified by:
      clearOptions in interface DatabaseStatement
    • addBatch

      public DatabaseStatement addBatch()
      Description copied from interface: DatabaseStatement
      Adds a batch operation to the statement.
      Specified by:
      addBatch in interface DatabaseStatement
      Returns:
      the updated SimpleDatabaseStatement object
    • withNullParameter

      public DatabaseStatement withNullParameter()
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as NULL.
      Specified by:
      withNullParameter in interface DatabaseStatement
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(Object object)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement with a specified object.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      object - the object to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(Object object, int sqlType)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement with a specified object and SQL type.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      object - the object to set as the parameter
      sqlType - the SQL type of the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(boolean value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a boolean value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the boolean value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(String value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a string value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the string value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(int value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as an integer value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the integer value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(long value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a long value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the long value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(short value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a short value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the short value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(byte value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a byte value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the byte value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(float value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a float value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the float value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(double value)
      Description copied from interface: DatabaseStatement
      Sets a parameter in the statement as a double value.
      Specified by:
      withParameter in interface DatabaseStatement
      Parameters:
      value - the double value to set as the parameter
      Returns:
      the updated SimpleDatabaseStatement object
    • withParameter

      public DatabaseStatement withParameter(InputStream inputStream)
      Specified by:
      withParameter in interface DatabaseStatement
    • execute

      public boolean execute()
      Description copied from interface: DatabaseStatement
      Executes the SQL statement.
      Specified by:
      execute in interface DatabaseStatement
      Returns:
      true if the execution was successful, false otherwise
    • executeUpdate

      public int executeUpdate()
      Description copied from interface: DatabaseStatement
      Executes an update SQL statement.
      Specified by:
      executeUpdate in interface DatabaseStatement
      Returns:
      the number of rows affected
    • executeLargeUpdate

      public long executeLargeUpdate()
      Description copied from interface: DatabaseStatement
      Executes a large update SQL statement.
      Specified by:
      executeLargeUpdate in interface DatabaseStatement
      Returns:
      the number of rows affected
    • executeQuery

      public void executeQuery(QueryReader reader)
      Description copied from interface: DatabaseStatement
      Executes a query SQL statement and processes the results with a QueryReader.
      Specified by:
      executeQuery in interface DatabaseStatement
      Parameters:
      reader - the QueryReader to process the query results
    • fetchRow

      public void fetchRow(QueryReader reader)
      Description copied from interface: DatabaseStatement
      Fetches the first row from the result set.
      Specified by:
      fetchRow in interface DatabaseStatement
      Parameters:
      reader - the QueryReader to process the first row
    • fetchAllRows

      public void fetchAllRows(QueryReader reader)
      Description copied from interface: DatabaseStatement
      Fetches all rows from the result set.
      Specified by:
      fetchAllRows in interface DatabaseStatement
      Parameters:
      reader - the QueryReader to process all rows
    • executeBatch

      public int[] executeBatch()
      Description copied from interface: DatabaseStatement
      Executes a batch of SQL statements.
      Specified by:
      executeBatch in interface DatabaseStatement
      Returns:
      an array of update counts indicating the success of each command
    • executeLargeBatch

      public long[] executeLargeBatch()
      Description copied from interface: DatabaseStatement
      Executes a large batch of SQL statements.
      Specified by:
      executeLargeBatch in interface DatabaseStatement
      Returns:
      an array of update counts indicating the success of each command