public class DatabaseMetaDataFactory
extends java.lang.Object
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)
}
}
Constructor and Description |
---|
DatabaseMetaDataFactory() |
Modifier and Type | Method and 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[]).
|
public static java.sql.ResultSet getTables(java.lang.String[] tableNames, java.lang.String catalog)
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)
tableNames
- The tables that has to be in the ResultSet.catalog
- a catalog namepublic static java.sql.ResultSet getColumns(java.lang.String[] columnNames, int[] columnTypes)
columnNames
- The column names.columnTypes
- The sql Types of the columns.Types
Copyright © 1999-2020 by i-net software GmbH