A report can be connected to a MySQL database at run time — define the connection and a SQL data source, read its columns, and bind them to a band.

Define the MySQL database and source.
StiMySqlDatabase db = new StiMySqlDatabase("test", "test",
    "url=jdbc:mysql://localhost:3306/sakila;user=root;password=***;database=sakila");
report.getDictionary().getDatabases().add(db);

StiMySqlSource source = new StiMySqlSource("test.actors", "actors", "actors", "select * from actor");
report.getDictionary().getDataSources().add(source);
Read the columns, then render.
StiMySqlAdapter adapter = new StiMySqlAdapter(db.getConnectionString());
Class.forName(adapter.getDriverName());
Connection con = StiDictionaryHelper.getConnection(adapter.getJdbcParameters());

StiTableFieldsRequest request = StiDataColumnsUtil.getFields(con, source.getQuery(), source);
for (StiSqlField field : request.getColumns())
    source.getColumns().add(new StiDataColumn(field.getName(), field.getName(), field.getSystemType()));

report.Render();

How it works. The data source is populated from the live query schema, so a report can be generated against a MySQL table without a designed template.
На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

Creating Report with MySQL Database at Runtime

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.