Interface MigrationContext


public interface MigrationContext
What a JavaMigration may do to the database it is migrating.
  • Method Summary

    Modifier and Type
    Method
    Description
    The runtime's own database object: com.codename1.db.Database in an application, com.codename1.backend.Database on a server.
    The engine being migrated.
    void
    execute(String sql, Object[] params)
    Runs one statement.
    query(String sql, Object[] params)
    Runs one query and returns every row with every value as text, null where the column is null.
  • Method Details

    • dialect

      String dialect()
      The engine being migrated.
      Returns:
      sqlite, postgresql or mysql; MariaDB answers mysql
    • execute

      void execute(String sql, Object[] params) throws IOException
      Runs one statement.
      Parameters:
      sql - a single statement, with ? for each parameter
      params - the parameter values, or null for none
      Throws:
      IOException - if the database refuses it
    • query

      List<String[]> query(String sql, Object[] params) throws IOException
      Runs one query and returns every row with every value as text, null where the column is null. Text is the one representation every engine and both runtimes agree on; a migration that needs typed access uses connection().
      Parameters:
      sql - a single query, with ? for each parameter
      params - the parameter values, or null for none
      Returns:
      the rows in order
      Throws:
      IOException - if the database refuses it
    • connection

      Object connection()
      The runtime's own database object: com.codename1.db.Database in an application, com.codename1.backend.Database on a server. Test it with instanceof before casting.
      Returns:
      the connection the migration runs on