Package com.inet.report.database
Class JdbcData
- java.lang.Object
-
- com.inet.report.database.BaseDataFactory
-
- com.inet.report.database.JdbcData
-
- All Implemented Interfaces:
DataFactory
,java.io.Serializable
- Direct Known Subclasses:
Database
public abstract class JdbcData extends BaseDataFactory
Abstract implementation of DataFactory for JDBC data.- Since:
- 13.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JdbcData()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getColumnName(java.lang.String colName, java.lang.String alias, int driverVersion, TableSource ts, int colIdx)
Returns the column name dependent of the database.java.util.List<ColumnInfo>
getColumns(TableSource ts)
Returns the column information for a TableSourceprotected abstract java.sql.ResultSet
getProcedureColumns(Datasource ds, java.lang.String catalog, java.lang.String schema, java.lang.String procedure)
Is used from#getColumns(TableSource)
if the TableSource based on a stored procedure.protected abstract java.sql.ResultSet
getProcedures(Datasource ds, java.lang.String catalog)
Is used from#getTableSourceInfos(Datasource, String)
to find a list of stored procedures.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.protected abstract java.lang.String
getSourceNameWithChange(TableSource ts, boolean escapeEverything)
Returns the source name like catalog.schema.table.abstract com.inet.report.database.sql.SqlSyntax
getSqlSyntax()
Returns the SQL syntax definition instance for this data factory.protected abstract java.sql.ResultSet
getTables(Datasource ds, java.lang.String catalog)
Is used from#getTableSourceInfos(Datasource, String)
to find a list of tables and views.TableData
getTableSourceData(TableSource ts)
Is called from getReportData to request the data of a single TableSource if the TableSource is not a joined table or view.java.util.Map<java.lang.String,TableSourceInfo>
getTableSourceInfos(Datasource ds, java.lang.String catalog)
Returns a map of objects in the database which can return table data.protected java.lang.String
patchSQL(java.lang.String sql)
Patch the sql to make some database special hacksboolean
supportsCommands()
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
-
-
-
-
Method Detail
-
getTableSourceData
@Nonnull public 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.- 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 java.util.Map<java.lang.String,TableSourceInfo> getTableSourceInfos(Datasource ds, java.lang.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
.- 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
public java.util.List<ColumnInfo> getColumns(TableSource ts) throws ReportException
Returns the column information for a TableSource- 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 java.sql.ResultSet getTables(Datasource ds, java.lang.String catalog) throws java.sql.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:
java.sql.SQLException
- if a database access error occursReportException
- if the creation of a Connection failed.- Since:
- 6.1
-
getProcedures
protected abstract java.sql.ResultSet getProcedures(Datasource ds, java.lang.String catalog) throws java.sql.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:
java.sql.SQLException
- if a database access error occursReportException
- if creating a Connection failed.- Since:
- 7.6
-
getProcedureColumns
protected abstract java.sql.ResultSet getProcedureColumns(Datasource ds, java.lang.String catalog, java.lang.String schema, java.lang.String procedure) throws java.sql.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:
java.sql.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 java.lang.String getColumnName(java.lang.String colName, java.lang.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
protected abstract java.lang.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 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
@Nonnull protected java.lang.String patchSQL(@Nonnull java.lang.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
-
-