Class JdbcData

All Implemented Interfaces:
DataFactory, Serializable
Direct Known Subclasses:
Database

public abstract class JdbcData extends BaseDataFactory
Abstract implementation of DataFactory for JDBC data.
Since:
13.0
See Also:
  • Constructor Details

    • JdbcData

      public JdbcData()
  • Method Details

    • getTableSourceData

      @Nonnull public @Nonnull TableData getTableSourceData(TableSource ts) throws ReportException
      Is called from getReportData to request the data of a single TableSource if the TableSource is not a joined table or view. So it's called for procedures, commands and single tables or views.

      If you have define a column of type DatabaseMetaData.procedureColumnIn then you can get the current value with:

       Object value = ts.getInputParameters().get(x).getValue();
       
      This required that getReportDataPerInstance() must return true.
      Specified by:
      getTableSourceData in interface DataFactory
      Overrides:
      getTableSourceData in class BaseDataFactory
      Parameters:
      ts - The current table source
      Returns:
      The resulting data, never null.
      Throws:
      ReportException - if error occurs in the API access
    • getReportDataPerInstance

      public boolean getReportDataPerInstance()
      Override this method only if you use subreport(s) and you set the data for the report with the getReportData or DataFactory.fetchData(Engine, FetchTables, DataCollector) method. For more information please refer to the sample Main_and_Subreport_Data_WithExternalResultSet.java.
      With this method you can specify whether the engine should call getReportData per subreport instance or only once for each of the subreports in the executed report. The same subreport can execute multiple time in a report with different parameters depending on its location. A subreport instance means one execution of one subreport. The method should return true if you want to set the different report data depending on the state of the report or if you want to set data depending on one or more parameter values. If you want to set data only once per sub-report, this function must return false. For example if you have a sub-report taking one prompt p0, and getReportDataPerInstance() returns true, then your sub-report will be called $n$ times whenever the value for p0 has been changed. So if your report has sub-reports and your sub-report prompts are linked with fields of the main report and you want to set the data whenever the sub-report prompts change, let getReportDataPerInstance() return true.
      Specified by:
      getReportDataPerInstance in interface DataFactory
      Overrides:
      getReportDataPerInstance in class BaseDataFactory
      Returns:
      true if the engine should invoke getReportData for every subreport instance or false otherwise.
    • getTableSourceInfos

      @Nonnull public @Nonnull Map<String,TableSourceInfo> getTableSourceInfos(Datasource ds, String catalog) throws ReportException
      Returns a map of objects in the database which can return table data. It can contain tables, views, stored procedures or your own objects. Keys of the returned map are table names and values are objects of type TableSourceInfo.

      If you want return parameter columns with type DatabaseMetaData.procedureColumnIn then DataFactory.getReportDataPerInstance() must return true and the TableSourceInfo must of type TableSourceInfo.TYPE_SPROC.

      Parameters:
      ds - datasource which describes the data
      catalog - an optional catalog
      Returns:
      a map of available objects, never null
      Throws:
      ReportException - if any error occurs
    • getColumns

      public List<ColumnInfo> getColumns(TableSource ts) throws ReportException
      Returns the column information for a TableSource.

      If you want return parameter columns with type DatabaseMetaData.procedureColumnIn then DataFactory.getReportDataPerInstance() must return true and the TableSourceInfo must of type TableSourceInfo.TYPE_SPROC.

      Specified by:
      getColumns in interface DataFactory
      Overrides:
      getColumns in class BaseDataFactory
      Parameters:
      ts - the table source to get the data for
      Returns:
      A list with column information, can be empty but not null
      Throws:
      ReportException - if any error occurs
    • supportsCommands

      public boolean supportsCommands()
      If this data factory supports a TableSource of type command. If true the designer show the menu item for adding commands. The default value is false. For JDBC data factories this flag is true.
      Returns:
      the flag value
    • getTables

      protected abstract ResultSet getTables(Datasource ds, String catalog) throws SQLException, ReportException
      Is used from #getTableSourceInfos(Datasource, String) to find a list of tables and views.
      Parameters:
      ds - The current Datasource containing the Connection.
      catalog - The catalog/database set in login dialog of i-net Designer.
      Returns:
      A ResultSet with the structure of DatabaseMetaData.getTables()
      Throws:
      SQLException - if a database access error occurs
      ReportException - if the creation of a Connection failed.
      Since:
      6.1
    • getProcedures

      protected abstract ResultSet getProcedures(Datasource ds, String catalog) throws SQLException, ReportException
      Is used from #getTableSourceInfos(Datasource, String) to find a list of stored procedures. Returns the procedures meta data for a datasource and catalog as defined by DatabaseMetaData.getProcedures(String, String, String)
      Parameters:
      ds - the datasource to connect to (if not already connected)
      catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
      Returns:
      each row is a procedure description
      Throws:
      SQLException - if a database access error occurs
      ReportException - if creating a Connection failed.
      Since:
      7.6
    • getProcedureColumns

      protected abstract ResultSet getProcedureColumns(Datasource ds, String catalog, String schema, String procedure) throws SQLException, ReportException
      Is used from #getColumns(TableSource) if the TableSource based on a stored procedure.
      Parameters:
      ds - The Datasource containing the Connection.
      catalog - The catalog/database set in login dialog of i-net Designer.
      schema - The table owner or null.
      procedure - The procedure name.
      Returns:
      A ResultSet with the structure of DatabaseMetaData.getProcedureColumns
      Throws:
      SQLException - This SQLException will be show in a message box in i-net Designer.
      ReportException - if the creation of a Connection failed.
      Since:
      7.6
    • getColumnName

      protected String getColumnName(String colName, String alias, int driverVersion, TableSource ts, int colIdx)
      Returns the column name dependent of the database.
      Parameters:
      colName - the column name
      alias - the column alias (required for MySQL Connector5.x only)
      driverVersion - the driver version (required for MySQL Connector5.x only)
      ts - the table source
      colIdx - the column index (required for Informix only)
      Returns:
      the name
      Since:
      15.0
    • getSourceNameWithChange

      protected abstract String getSourceNameWithChange(TableSource ts, boolean escapeEverything)
      Returns the source name like catalog.schema.table. Overwrites the catalog and schema names if these was changed in the Datasource.
      Parameters:
      ts - the table source
      escapeEverything - True if the complete sql identifier should be quoted false otherwise
      Returns:
      the name
      Since:
      15.0
    • getSqlSyntax

      public abstract com.inet.report.database.sql.SqlSyntax getSqlSyntax()
      Returns the SQL syntax definition instance for this data factory.
      Returns:
      the SQL syntax definition instance for this data factory
      Since:
      15.0
    • patchSQL

      @Nonnull protected @Nonnull String patchSQL(@Nonnull @Nonnull String sql)
      Patch the sql to make some database special hacks
      Parameters:
      sql - the standard sql
      Returns:
      the patched or original sql
      Since:
      22.4