|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.townleyenterprises.persistence.QueryHandler
This class encapsulates the core functionality of making a database query into a single place. Queries are executed based on the settings of certain properties for the class, and listeners may be registered to receive notification of each row to be processed.
Prior to version 2.1, this class relied on a pre-release version of Jaxor being available to perform tasks such as setting the query parameters and supplying connections. With version 2.1, this link is no longer present, however the previous behavior is available by placing one of the appropriate extensions in the classpath prior to the main te-common.jar.
Constructor Summary | |
QueryHandler()
The constructure allocates a new set of resources for executing a specific query. |
|
QueryHandler(ConnectionFactory factory)
This constructor allows setting a connection factory for this instance. |
Method Summary | |
void |
abort()
This method causes the query handler to abort processing the active query. |
void |
addQueryListener(QueryListener listener)
This method adds a QueryListener to the list of objects which will retrieve notifications of various QueryHandler events. |
void |
execute(java.lang.String query,
java.lang.Object[] params)
This method actually executes the query based on the configured property values and the query and query parameters. |
protected void |
nextRow(QueryEvent event)
This method is called by the QueryHandler after notifiying the listeners of the next row. |
void |
removeQueryListener(QueryListener listener)
This method is used to unregister an object from the list of listeners. |
void |
setConnectionFactory(ConnectionFactory factory)
This method initializes the connection factory for this instance. |
static void |
setDefaultConnectionFactory(ConnectionFactory factory)
This method is used to set the default conneciton factory for all instances of this class |
void |
setStart(int start)
This method sets the start row for processing the results. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public QueryHandler()
public QueryHandler(ConnectionFactory factory)
factory
- the connection factory to useMethod Detail |
public void abort()
public void addQueryListener(QueryListener listener)
listener
- the QueryListenerpublic void execute(java.lang.String query, java.lang.Object[] params) throws java.sql.SQLException
NOTE: this code is borrowed almost exactly from Jaxor's BaseFinder.executeQuery method.
query
- the SQL query to be executedparams
- the parameters to be supplied to the query
count
number of rows,
only the specific rows will be retrieved. If there
are less rows than the start index, an empty list will
be returned.
java.sql.SQLException
- if an SQLException was thrown during query executionpublic void removeQueryListener(QueryListener listener)
listener
- the QueryListerpublic void setConnectionFactory(ConnectionFactory factory)
factory
- the ConnectionFactory instancepublic void setStart(int start)
protected void nextRow(QueryEvent event) throws java.sql.SQLException
event
- the QueryEvent to propagate
java.sql.SQLException
- if there is an issue with processing the result setpublic static void setDefaultConnectionFactory(ConnectionFactory factory)
factory
- the factory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |