|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.tree.DefaultMutableTreeNode | +--com.klg.jclass.datasource.DataSourceTreeNode | +--com.klg.jclass.datasource.BaseMetaData | +--com.klg.jclass.datasource.jdbc.MetaData
This MetaData connects to a data source through JDBC. Each instance of this MetaData will have a particular query associated with it. This MetaData will execute that query and cache the results.
When used in the context of the JClass HiGrid, multiple result sets will be cached. These result sets will be based on the same query but with different parameters. When used in JClass HiGrid, this control will be a node in the MetaTree describing the relationships between SQL queries.
Transaction support is built on top of JDBC transactions. To turn on transaction support, "auto commit" must be disabled on the JDBC Connection which is passed into this object. Alternatively, calling setAutoCommit(false) on this MetaData object does the same. Since the same Connection can be shared among one or more MetaData objects calling MetaData.setAutoCommit(false) is redundant on all but the first.
Commits and rollbacks happen on a per Connection basis. If all MetaData objects share the same Connection, modifications spanning levels will be committed as group within one transaction. If multiple Connections objects are used however, say for example, one per MetaData object, RootMetaData.rollbackTransaction() will recurse and rollback transaction on all those MetaData objects which have not yet been successfully committed. If they have been committed, they are not rolledback and their changes are permanent. Those on which a successful commitTransaction has not occurred will be rolled back.
The default is to accept the JDBC default which is "auto commit" is "true". This means that unless the auto commit on the Connection is explicitly set to "false" (by calling setAutoCommit(false) on the Connection object directly or indirectly through MetaData.setAutoCommit(false), each statement will be commit upon completion.
Field Summary | |
static int |
DEFAULT_DESIGN_TIME_MAX_ROWS
|
protected static int |
designTimeMaxRows
|
protected String |
driverTable
The table which drives a row when there is more than one table for a row. |
protected com.klg.jclass.datasource.jdbc.DataTableConnection |
ds_connection
Encapsulates JDBC connection. |
protected Vector |
join_columns
These are the keys columns used by this control to link to its parent. |
protected static int |
NOT_FOUND
|
protected int |
numColumns
Number of colums for this ds. |
protected boolean |
open
Returns true if this instance been initialized. |
protected com.klg.jclass.datasource.jdbc.MetaData |
parent_control
This data control's parent. |
protected com.klg.jclass.datasource.util.SqlParser |
parser
|
protected com.klg.jclass.datasource.jdbc.PersistorModel |
persistor
Class responsible for saving changes to db |
protected String |
query
The query statement is used to populate this DataTable |
protected PreparedStatement |
query_statement
The JDBC version of the query. |
protected Vector |
tableColumnIndexes
Vector of column indexes for a table. |
protected Vector |
tables
Vector of database tables for this level. |
protected Hashtable |
tableToPrimaryKeyMap
Primary keys. |
Fields inherited from class com.klg.jclass.datasource.BaseMetaData |
binding, bufferSize, cacheChildren, columns, commitPolicy, counter, currentBookmark, currentDataTable, dataModel, deletePermissions, description, idxToColumnMap, initialHashtableSize, insertPermissions, maxRows, metaDataID, provider, showDeletedRows, storeClass, updatePermissions |
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Fields inherited from interface com.klg.jclass.datasource.MetaDataModel |
COMMIT_LEAVING_ANCESTOR, COMMIT_LEAVING_RECORD, COMMIT_MANUALLY, TYPE_BIG_DECIMAL, TYPE_BOOLEAN, TYPE_BYTE, TYPE_BYTE_ARRAY, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_SHORT, TYPE_SQL_DATE, TYPE_SQL_TIME, TYPE_SQL_TIMESTAMP, TYPE_STRING, TYPE_UTIL_DATE |
Constructor Summary | |
MetaData(com.klg.jclass.datasource.DataModel dataModel,
com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
General purpose MetaData Constructor. |
|
MetaData(com.klg.jclass.datasource.DataModel dataModel,
com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection,
String query)
Convenience root constructor. |
|
MetaData(com.klg.jclass.datasource.DataModel dataModel,
com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection,
String query,
int maxRows)
Convenience root constructor which allows max rows to be set. |
|
MetaData(com.klg.jclass.datasource.DataModel dataModel,
com.klg.jclass.datasource.MetaDataModel parent,
com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
After first calling the Root constructor, call this to add master-detail relationships. |
Method Summary | |
void |
addColumn(com.klg.jclass.datasource.ColumnModel column)
Adds a column to the list of column objects. |
void |
addColumnToIdentifiers(String column_name,
int position)
Adds the column to the internal mapping |
void |
clear()
For internal use only. |
void |
commitTransaction()
Recursivly Commits the transaction. |
com.klg.jclass.datasource.jdbc.DataTable |
executeQuery()
Internal method, passes parent row to new DataTables. |
com.klg.jclass.datasource.jdbc.DataTable |
executeQuery(long parent_row)
Execute the query. |
protected void |
finalize()
Free any lingering jdbc resources. |
boolean |
getAutoCommit()
Default implementation: returns true. |
Vector |
getColumnIndexesForTable(String table)
Convenience method: returns this table's column indexes. |
com.klg.jclass.datasource.jdbc.DataTableConnection |
getDataTableConnection()
Gets this data control's DataTableConnection. |
static int |
getDesignTimeMaxRows()
Gets the maximum number of rows returned from a database at design-time. |
String |
getDriverTable()
Returns the name of the table used to drive requeries when more than one table contributes columns to a row. |
int |
getDriverTableIndex()
Returns the index of the driver table in the list of tables. |
Vector |
getJoinColumns()
Return the list of join columns. |
Object |
getNativeMetaData()
Return the native meta data object. |
com.klg.jclass.datasource.util.SqlParser |
getParser()
Returns the parser of the sql query statement. |
com.klg.jclass.datasource.jdbc.PersistorModel |
getPersistor()
Return the PersistorModel instance which is to be used to save changes to the data base. |
String |
getStatement()
Return the current query statement. |
Vector |
getTables()
Convenience method: returns the tables associated with this level. |
String |
getWhereClause()
Return the current "where" clause used for getting data. |
boolean |
isOpen()
Returns true if this MetaData object has been initialized. |
boolean |
isUpdateAllowedOnColumn(String column)
Returns true if an update is allowed on this column. |
void |
joinOnParentColumn(String parentColumn,
String childColumn)
Adds a key column which will be used to join to this control's parent. |
com.klg.jclass.datasource.jdbc.DataTable |
open()
Initializes by causing the ResultSetMetaData to be loaded. |
void |
rollbackTransaction()
Recursivly rolls back the transaction. |
void |
setAutoCommit(boolean value)
Sets the auto commit flag. |
void |
setColumnTableRelations(String table,
String[] columnNames)
Explicitly sets the relationships between tables and columns. |
void |
setConnection(com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
Sets this data control's connection to DataTableConnection. |
static void |
setDesignTimeMaxRows(int max)
Sets the maximum number of rows returned from a database at design-time. |
void |
setDriverTable(String driverTable)
Sets the name of the table whose primary key will be used to requery a row when more than one table contributes columns to a row. |
void |
setParameter(int number,
Object value,
int type)
Sets a particular parameter in the sql statement. |
void |
setPersistor(String className)
Sets the class which is to be used for saving data modifications back to the originating data base. |
void |
setPrimaryKeys(String table,
String[] columnNames)
Sets the primary keys for a table. |
void |
setStatement(String query)
Set the SQL statement used to retrieve data. |
void |
setWhereClause(String whereClause)
Change or add a where clause for the existing query statement. |
Methods inherited from class com.klg.jclass.datasource.DataSourceTreeNode |
getChildren, getFirstChild, getIterator, getIterator, getIterator, getIterator, getLastChild, getNextChild, getPreviousChild, hasChildren, insert, isChildOf, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface javax.swing.tree.TreeNode |
children, getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf |
Field Detail |
public static final int DEFAULT_DESIGN_TIME_MAX_ROWS
protected com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection
protected transient PreparedStatement query_statement
protected int numColumns
protected Hashtable tableToPrimaryKeyMap
com.sun.java.util
class.protected com.klg.jclass.datasource.jdbc.MetaData parent_control
protected Vector join_columns
protected Vector tables
protected String query
protected Vector tableColumnIndexes
protected boolean open
protected String driverTable
protected com.klg.jclass.datasource.jdbc.PersistorModel persistor
protected com.klg.jclass.datasource.util.SqlParser parser
protected static int designTimeMaxRows
protected static int NOT_FOUND
Constructor Detail |
public MetaData(com.klg.jclass.datasource.DataModel dataModel, com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
MetaData Orders = new MetaData(this, connection);
Orders.setStatement("select * from Orders where OrderID < ?");
Orders.setDescription("Orders");
Orders.setParameter(1, new Integer(OrderIdParameter), java.sql.Types.INTEGER);
Orders.setMaxRows(5);
getMetaDataTree().setRoot(Orders);
getDataTableTree().setRoot(Orders.executeQuery());
As this example shows, this constructor does not automatically
add this MetaData object to the meta data tree as do the
convenience constructors. It must be added manually. Since in this
example we created the root-level node we must also manually
set the root of the data table tree.
Your query must include all the primary key columns for each table in the select statement, otherwise update anomalies may occur.
dataModel
- the DataModelpublic MetaData(com.klg.jclass.datasource.DataModel dataModel, com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection, String query, int maxRows) throws DataModelException
Your query must include all the primary key columns for each table in the select statement, otherwise update anomalies may occur.
dataModel
- the DataModel to which
this meta data object will be added.query
- the String sql query the results of which will
form the root level in the MetaDateTree.maxRows
- an int restricting the number of rows this
query can return.
DataModelException
- If the operation fails.public MetaData(com.klg.jclass.datasource.DataModel dataModel, com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection, String query) throws DataModelException
Your query must include all the primary key columns for each table in the select statement, otherwise update anomalies may occur.
dataModel
- the DataModel to which
this meta data object will be added.query
- the String sql query the results of which will
form the root level in the MetaDateTree.
DataModelException
- If the operation fails.public MetaData(com.klg.jclass.datasource.DataModel dataModel, com.klg.jclass.datasource.MetaDataModel parent, com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
dataModel
- the HiGrid DataModel to which
this meta data object will be added.parent
- the MetaData object which will be the master
of this detail MetaData object.Method Detail |
public void setConnection(com.klg.jclass.datasource.jdbc.DataTableConnection ds_connection)
public com.klg.jclass.datasource.jdbc.DataTableConnection getDataTableConnection()
public void setStatement(String query) throws DataModelException
query
- a String, the SQL statement to be executed
DataModelException
- If set fails.public void setWhereClause(String whereClause) throws DataModelException
If this is a child level, you must preserve the number and order of the join parameters (i.e. the order in which they were added by calls to the joinOnParentColumn method).
For example, if your original query was this:
select * from OrderDetails where OrderID = ?"
calling setWhereClause("where OrderID = ? and ProductID = 'AMPB5'") results
in this new query:
select * from OrderDetails where OrderID = ? and ProductID = 'AMPB5'
whereClause
- a String which is the new where clause
DataModelException
- If the set fails.joinOnParentColumn(java.lang.String, java.lang.String)
public String getWhereClause()
SqlParser
public String getStatement()
setStatement(java.lang.String)
,
setWhereClause(java.lang.String)
public void joinOnParentColumn(String parentColumn, String childColumn)
childColumn
- a String indicating to which child column the
parent column should match, required because parent column names can be
different than child column names; if the column is aliased, used the alias,
otherwise use the name as it appears in the select statement
([catalog.][schema.][table.]column.)public void setParameter(int number, Object value, int type) throws DataModelException
number
- an int indicating the position of the parameter,
starts at 1.value
- the Object which is to be set
DataModelException
- If setParameter fails.public Vector getTables()
public Vector getColumnIndexesForTable(String table)
table
- the String name of a table; if aliased, used the alias,
otherwise use the table name as it appears in the select statement
([catalog.][schema.]table)
public com.klg.jclass.datasource.jdbc.DataTable executeQuery() throws DataModelException
DataModelException
- If executeQuery fails.public com.klg.jclass.datasource.jdbc.DataTable executeQuery(long parent_row) throws DataModelException
DataModelException
- If executeQuery failspublic void addColumnToIdentifiers(String column_name, int position) throws DataModelException
column_name
- a String which is the column alias or the column name
as it appears in the select statement ([catalog.][schema.][table.]column)
DataModelException
- If the mapping fails.BaseMetaData.addColumn(com.klg.jclass.datasource.ColumnModel)
public void clear()
BaseMetaData
clear
in interface MetaDataModel
clear
in class BaseMetaData
public void setPrimaryKeys(String table, String[] columnNames)
table
- a String which is the table alias or table name as it
appears in the select statement (([catalog.][schema.]table)public com.klg.jclass.datasource.jdbc.DataTable open() throws DataModelException
DataModelException
- If the operation fails.public void setColumnTableRelations(String table, String[] columnNames) throws DataModelException
table
- a String, the name to which (a subset of the columns belong);
use the table name as it appears in the FROM clause; don't use alias
DataModelException
- If the operation fails.public boolean isOpen()
open
public void setDriverTable(String driverTable)
driverTable
- a String, the table alias or name as it appears in the
select statement ([catalog.][schema.]table)public String getDriverTable()
public int getDriverTableIndex()
public void setAutoCommit(boolean value) throws DataModelException
setAutoCommit
in interface MetaDataModel
setAutoCommit
in class BaseMetaData
DataModelException
- If the operation fails.public boolean getAutoCommit() throws DataModelException
getAutoCommit
in interface MetaDataModel
getAutoCommit
in class BaseMetaData
DataModelException
- If the operation fails.commitTransaction()
,
rollbackTransaction()
public void rollbackTransaction() throws DataModelException
rollbackTransaction
in interface MetaDataModel
rollbackTransaction
in class BaseMetaData
DataModelException
- If rollback fails.MetaDataModel.getAutoCommit()
public void commitTransaction() throws DataModelException
commitTransaction
in interface MetaDataModel
commitTransaction
in class BaseMetaData
DataModelException
- If commit fails.MetaDataModel.getAutoCommit()
public boolean isUpdateAllowedOnColumn(String column) throws DataModelException
isUpdateAllowedOnColumn
in interface MetaDataModel
isUpdateAllowedOnColumn
in class BaseMetaData
DataModelException
- If primary keys not found.BaseMetaData.getUpdateAllowed(java.lang.String)
,
BaseMetaData.setUpdateAllowed(java.lang.String, boolean)
public com.klg.jclass.datasource.util.SqlParser getParser()
SqlParser
public void addColumn(com.klg.jclass.datasource.ColumnModel column) throws DataModelException
addColumn
in interface MetaDataModel
addColumn
in class BaseMetaData
DataModelException
- If column add fails.BaseMetaData.addColumn(com.klg.jclass.datasource.ColumnModel)
public Object getNativeMetaData()
getNativeMetaData
in interface MetaDataModel
getNativeMetaData
in class BaseMetaData
public void setPersistor(String className) throws DataModelException
className
- the name of the class on which a
Class.forName(className).newInstance will be done
DataModelException
- If loading the class fails.public com.klg.jclass.datasource.jdbc.PersistorModel getPersistor()
setPersistor(java.lang.String)
public static void setDesignTimeMaxRows(int max)
Beans.isDesignTime()
public static int getDesignTimeMaxRows()
setDesignTimeMaxRows(int)
public Vector getJoinColumns()
protected void finalize()
finalize
in class Object
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |