Class MySQL

All Implemented Interfaces:
SqlConfig<MySQL>, SqlGet, SqlPost

public class MySQL extends JdbcExecutor<MySQL>
MySQL helper that provides a common API for operating with MySQL.

It is recommended to use a single instance: MySQL db = MySQL.getInstance();

Provides:

  • Assertions with await support
  • Data manipulation operations such as create, update, and clean

For more information, see JdbcExecutor.

  • Field Details

  • Constructor Details

    • MySQL

      public MySQL(String dbUrl, String username, String passwd)
      Creates a new MySQL database helper instance with the specified connection parameters.
      Parameters:
      dbUrl - the JDBC connection URL for the MySQL database
      username - the username used to authenticate with the database
      passwd - the password used to authenticate with the database
      Throws:
      IllegalArgumentException - if any of the required parameters are null or empty
    • MySQL

      public MySQL()
      Constructs MySQL client configuration.

      Loads configuration values from a YAML file.

      Example:

      MySQL db = new MySQL();

       mysql:
         url: 'jdbc:mysql://localhost:3308'
         username: user
         password: pass
         await: 1000 (optional)
       
      See Also:
  • Method Details

    • getInstance

      public static MySQL getInstance()
      Returns the singleton instance of MySQL with config builder MySQL().

      This implementation is thread-safe using method-level synchronization.

      Returns:
      the singleton instance of MySQL
      Throws:
      IllegalArgumentException - if the configuration contains invalid values
      See Also:
    • assertCountInTableBuilder

      @Step("(DB)[ASSERT] Table: \'{tableName}\' contains EXACTLY <{expectedCount}> record/s {conditions}") protected void assertCountInTableBuilder(String tableName, String conditions, @Param(mode=HIDDEN) Object[][] conditionsArray, String expectedCount, @Param(mode=HIDDEN) int awaitMs)
    • recordExistsBuilder

      @Step("(DB)[ASSERT] Table \'{tableName}\' contains records {conditions}") protected void recordExistsBuilder(String tableName, String conditions, @Param(mode=HIDDEN) Object[][] conditionsArray, @Param(mode=HIDDEN) int awaitMs)
    • showDataFromTableMethod

      protected void showDataFromTableMethod(String tableName)
    • seeInDbByCondMethod

      @Step("(DB) Show data from table \'{tableName}\' {conditions}") protected void seeInDbByCondMethod(String tableName, String conditions)
    • getTableColumns

      protected String[] getTableColumns(String tableName)
      Returns the list of columns in the table.
      Parameters:
      tableName - table name in the format schema_name.table_name
      Returns:
      array containing column names