Package com.inet.report.database
Class JdbcData
java.lang.Object
com.inet.report.database.BaseDataFactory
com.inet.report.database.JdbcData
- All Implemented Interfaces:
DataFactory
,Serializable
- Direct Known Subclasses:
Database
Abstract implementation of DataFactory for JDBC data.
- Since:
- 13.0
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
getColumnName
(String colName, String alias, int driverVersion, TableSource ts, int colIdx) Returns the column name dependent of the database.Returns the column information for a TableSource.protected abstract ResultSet
getProcedureColumns
(Datasource ds, String catalog, String schema, String procedure) Is used from#getColumns(TableSource)
if the TableSource based on a stored procedure.protected abstract ResultSet
getProcedures
(Datasource ds, String catalog) Is used from#getTableSourceInfos(Datasource, String)
to find a list of stored procedures.boolean
Override this method only if you use subreport(s) and you set the data for the report with the getReportData orDataFactory.fetchData(Engine, FetchTables, DataCollector)
method.protected abstract String
getSourceNameWithChange
(TableSource ts, boolean escapeEverything) Returns the source name like catalog.schema.table.abstract com.inet.report.database.sql.SqlSyntax
Returns the SQL syntax definition instance for this data factory.protected abstract ResultSet
getTables
(Datasource ds, String catalog) Is used from#getTableSourceInfos(Datasource, String)
to find a list of tables and views.@Nonnull TableData
Is called from getReportData to request the data of a single TableSource if the TableSource is not a joined table or view.@Nonnull Map<String,
TableSourceInfo> getTableSourceInfos
(Datasource ds, String catalog) Returns a map of objects in the database which can return table data.protected @Nonnull String
Patch the sql to make some database special hacksboolean
If this data factory supports a TableSource of type command.Methods inherited from class com.inet.report.database.BaseDataFactory
fetchData, getColumns, getConfiguration, getTableSourceData, setConfiguration
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.inet.report.database.DataFactory
getVersion
-
Constructor Details
-
JdbcData
public JdbcData()
-
-
Method Details
-
getTableSourceData
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();
- Specified by:
getTableSourceData
in interfaceDataFactory
- Overrides:
getTableSourceData
in classBaseDataFactory
- 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 orDataFactory.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 interfaceDataFactory
- Overrides:
getReportDataPerInstance
in classBaseDataFactory
- 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 typeTableSourceInfo
.If you want return parameter columns with type
DatabaseMetaData.procedureColumnIn
thenDataFactory.getReportDataPerInstance()
must return true and theTableSourceInfo
must of typeTableSourceInfo.TYPE_SPROC
.- Parameters:
ds
- datasource which describes the datacatalog
- an optional catalog- Returns:
- a map of available objects, never null
- Throws:
ReportException
- if any error occurs
-
getColumns
Returns the column information for a TableSource.If you want return parameter columns with type
DatabaseMetaData.procedureColumnIn
thenDataFactory.getReportDataPerInstance()
must return true and theTableSourceInfo
must of typeTableSourceInfo.TYPE_SPROC
.- Specified by:
getColumns
in interfaceDataFactory
- Overrides:
getColumns
in classBaseDataFactory
- 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 occursReportException
- 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 byDatabaseMetaData.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 occursReportException
- 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 namealias
- the column alias (required for MySQL Connector5.x only)driverVersion
- the driver version (required for MySQL Connector5.x only)ts
- the table sourcecolIdx
- the column index (required for Informix only)- Returns:
- the name
- Since:
- 15.0
-
getSourceNameWithChange
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 sourceescapeEverything
- 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
Patch the sql to make some database special hacks- Parameters:
sql
- the standard sql- Returns:
- the patched or original sql
- Since:
- 22.4
-