Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public interface MigrationContext
What a
JavaMigration may do to the database it is migrating.Methods
public abstract String dialect() | The engine being migrated. |
public abstract void execute(String sql, Object[] params)
throws IOException | Runs one statement. |
public abstract 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. |
public abstract Object connection() | The runtime’s own database object: com.codename1.db.Database in an application, com.codename1.backend.Database on a server. |
Method details
dialect
public abstract String dialect()The engine being migrated.
Returns
sqlite, postgresql or mysql; MariaDB answers mysqlexecute
public abstract void execute(String sql, Object[] params)
throws IOExceptionRuns one statement.
Parameters
sqlString- a single statement, with
?for each parameter paramsObject[]- the parameter values, or null for none
Throws
IOException- if the database refuses it
query
public abstract List<String[]> query(String sql, Object[] params)
throws IOExceptionRuns 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
sqlString- a single query, with
?for each parameter paramsObject[]- the parameter values, or null for none
Returns
the rows in order
Throws
IOException- if the database refuses it
connection
public abstract 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