|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xj.anylogic.engine.connectivity.Query
public class Query
Query object for database connectivity
Works in 2 modes:
ResultSet object (see execute()) which can be
iterated to retrieve result values
ActiveObjects in the Replicated Active
Object element (see executeAndMap())
| Constructor Summary | |
|---|---|
Query(java.lang.String name,
Database database,
boolean selectFromTable,
java.lang.String tableNameOrQueryText)
Creates new Query for work only with execute() method |
|
Query(java.lang.String name,
Database database,
boolean selectFromTable,
java.lang.String tableNameOrQueryText,
java.lang.String[][] mapping)
Creates new Query for work in the Mapping mode (executeAndMap()
method)Note the execute() method is still available for this object |
|
| Method Summary | |
|---|---|
java.lang.Object |
createNewRowElementInstance()
Extension-point for element creation In the Mapping mode, this method should be overridden to create specifical element and return it |
void |
destroy()
Releases resources acquired by this object Also destroys all not destroyed contributors associated with this object Doest nothing if object is already destroyed |
ResultSet |
execute()
Executes query in the database and returns single ResultSetIf any error occurs, throws RuntimeExceptionConnects Database if it is not connected. |
int |
executeAndMap()
This method fills underlying collection or Replicated Active Object (created Active Objects are started automatically) with elements created from rows of database Query result This method works only in the Mapping mode |
int |
executeAndMap(boolean startActiveObjects)
This method fills underlying collection or Replicated Active Object with elements created from rows of database Query result This method works only in the Mapping mode |
java.lang.String |
getName()
Returns the name of this object |
void |
registerNewRowElement(java.lang.Object element,
boolean startActiveObjects)
Extension-point for element creation In the Mapping mode, this method should be overridden to start given element (previously created by createNewRowElementInstance() and parametrized) add it to the
underlying collection and return it |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Query(java.lang.String name,
Database database,
boolean selectFromTable,
java.lang.String tableNameOrQueryText)
Query for work only with execute() method
name - object name (decoration purpose)database - selectFromTable - tableNameOrQueryText -
public Query(java.lang.String name,
Database database,
boolean selectFromTable,
java.lang.String tableNameOrQueryText,
java.lang.String[][] mapping)
Query for work in the Mapping mode (executeAndMap()
method)execute() method is still available for this object
name - object name (decoration purpose)database - database to connect toselectFromTable - flag indicating what value is contained in parameter
tableNameOrQueryTexttableNameOrQueryText - selectFromTable is true
mapping - mappings array with dimensions N x 2 like:
new String[][] { { "fieldName0", "columnLabel0" },
{ "fieldName1", "columnLabel1" },
// ...
}
where
ActiveObject
AS
clause. If a SQL AS is not specified, the table column
name is assumed
| Method Detail |
|---|
public java.lang.Object createNewRowElementInstance()
public void registerNewRowElement(java.lang.Object element,
boolean startActiveObjects)
createNewRowElementInstance() and parametrized) add it to the
underlying collection and return it
startActiveObjects - defines either created Active Objects are started or notstart() method on
active object only if this parameter is truepublic final ResultSet execute()
ResultSetRuntimeExceptionDatabase if it is not connected. After this method call
Database remains connected.
ResultSet object; never nullResultSet.close() method after all needed
operations are completedpublic final int executeAndMap()
public final int executeAndMap(boolean startActiveObjects)
startActiveObjects - defines either created Active Objects are started or not
public java.lang.String toString()
public final java.lang.String getName()
public final void destroy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||