Package com.inet.report
Class DatabaseMetaDataFactory
- java.lang.Object
-
- com.inet.report.DatabaseMetaDataFactory
-
public class DatabaseMetaDataFactory extends java.lang.Object
This class is helpful if you want to use a self defined Database class as base for report design with i-net Designer. The i-net Designer calls some methods from Database class to receive meta data information of the database. To use the own Database class as base for report design these methods have to be overwritten. DatabaseMetaDataFactory can be used to create the ResultSet objects that will be returned from these methods.
An example for a Database class:public class MyDatabase extends Database { private final static String tableName = "customers"; private final static String[] tableColumnNames = new String[] {"customerid", "companyname", "address"}; private final static int[] tableColumnTypes = new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}; private final static Object[][]tableData = new Object[][]{{"ALFKI","Alfreds Futterkiste","Obere Str. 57"},{"ANATR", "Ana Trujillo Emparedados y helados", "Avda. de la ConstituciĆ³n 2222"}}; public boolean useJdbcDriver() { return false; } public ResultSet getTables(Datasource ds, String catalog)throws SQLException { return DatabaseMetaDataFactory.getTables(new String[]{tableName}); } public ResultSet getColumns(Datasource ds, String cat, String own, String tab) throws SQLException { if(tab.equalsIgnoreCase(tableName)) return DatabaseMetaDataFactory.getColumns(tableColumnNames,tableColumnTypes); else throw new SQLException("unknown table "+tab); } public void getReportData(Engine engine, String configs) throws ReportException { String columns[] = new String[tableColumnNames.length]; for (int i = 0; i < columns.length; i++) { columns[i]=tableName+"."+tableColumnNames[i]; //set full qualified column name } engine.setData(columns,tableData) } }
To use your own Database class as datasource, you need to create a user defined Data Source Configuration using the Data Source Manager and set your own Database class in the property "Database Class".
In i-net Designer you need to select the user defined Data Source Configuration in the Connection Manager.- Since:
- 6.1
-
-
Constructor Summary
Constructors Constructor Description DatabaseMetaDataFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.sql.ResultSet
getColumns(java.lang.String[] columnNames, int[] columnTypes)
Returns a ResultSet that has the structure of the ResultSet returned from DatabaseMetaData.getColumns().static java.sql.ResultSet
getTables(java.lang.String[] tableNames, java.lang.String catalog)
Creates a dummy ResultSet that has the structure defined for method DatabaseMetaData.getTables(String,String,String,String[]).
-
-
-
Method Detail
-
getTables
public static java.sql.ResultSet getTables(java.lang.String[] tableNames, java.lang.String catalog)
Creates a dummy ResultSet that has the structure defined for method DatabaseMetaData.getTables(String,String,String,String[]).
The column TABLE_TYPE contains the value "TABLE", the column TABLE_NAME contains the set table names.
All other columns contains value null.
The returned columns:
TABLE_CAT String => table catalog (may be null) TABLE_SCHEM String => table schema (may be null) TABLE_NAME String => table name TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". REMARKS String => explanatory comment on the table TYPE_CAT String => the types catalog (may be null) TYPE_SCHEM String => the types schema (may be null) TYPE_NAME String => type name (may be null) SELF_REFERENCING_COL_NAME String => name of the designated "identifier" column of a typed table (may be null) REF_GENERATION String => specifies how values in SELF_REFERENCING_COL_NAME are created. Values are "SYSTEM", "USER", "DERIVED". (may be null)
- Parameters:
tableNames
- The tables that has to be in the ResultSet.catalog
- a catalog name- Returns:
- A dummy ResultSet containg a list of table names.
- Since:
- 6.1
-
getColumns
public static java.sql.ResultSet getColumns(java.lang.String[] columnNames, int[] columnTypes)
Returns a ResultSet that has the structure of the ResultSet returned from DatabaseMetaData.getColumns().- Parameters:
columnNames
- The column names.columnTypes
- The sql Types of the columns.- Returns:
- A ResultSet with structure of ResultSet from DatabaseMetaData.getColumns().
- Since:
- 6.1
- See Also:
Types
-
-