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.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.