|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.data.jdbc.JDBCDataStore.QueryData
Provides an encapsulation of the connection, statement and result set of a JDBC query. This class solves the problem of "Where do we close JDBC resources when they are being used by multiple AttributeReaders?".
An alternative solution would be to have the FeatureReader manage the resources, however this will pose problems when combining JDBC Attribute Readers with other AttributeReaders and FeatureReaders. The QueryData solution works by holding all the needed resources and providing a close method that closes all the resources. When the close method is called any readers that are registered as QueryDataListeners for the query data will be notified. This will allow one AttributeReader to close the resources and any other AttributeReaders using the same resources will find out about it.
Constructor Summary | |
JDBCDataStore.QueryData(JDBCDataStore.FeatureTypeInfo featureTypeInfo,
java.sql.Connection conn,
java.sql.Statement statement,
java.sql.ResultSet resultSet,
Transaction transaction)
The constructor for the QueryData object. |
Method Summary | |
void |
addQueryDataListener(QueryDataListener l)
Adds a QueryDataListener to the list of listeners. |
java.io.IOException |
cast(java.lang.String message,
java.sql.SQLException sqlException)
A convience method that ensures we handle rollback on error correctly. |
void |
close(java.sql.SQLException sqlException)
Closes all the resources. |
void |
deleteCurrentRow()
|
protected void |
fireCloseEvent()
Fires the close event. |
java.sql.Connection |
getConnection()
|
JDBCDataStore.FeatureTypeInfo |
getFeatureTypeInfo()
DOCUMENT ME! |
java.sql.ResultSet |
getResultSet()
Gets the result set. |
Transaction |
getTransaction()
Returns transaction, this Query data is opperating against. |
boolean |
isInserting()
|
void |
removeQueryDataListener(QueryDataListener l)
Removes a QueryDataListener for the list of listeners. |
void |
setInserting(boolean isInserting)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JDBCDataStore.QueryData(JDBCDataStore.FeatureTypeInfo featureTypeInfo, java.sql.Connection conn, java.sql.Statement statement, java.sql.ResultSet resultSet, Transaction transaction)
featureTypeInfo
- DOCUMENT ME!conn
- The connection to the DB.statement
- The statement used to execute the query.resultSet
- The result set.transaction
- DOCUMENT ME!Method Detail |
public java.sql.ResultSet getResultSet()
public void close(java.sql.SQLException sqlException)
All resources are closed the QueryDataListener.queryDataClosed() is called on all QueryDataListeners.
The Connection is handled differently depending on if this is an AUTO_COMMIT Transaction or not.
error
is false
true
.
Jody Here: I have forced this method to handle maintaining conneciton status as it knows about Transactions and AttributeReaders do not.
USEAGE GUIDELINES:
sqlException
- DOCUMENT ME!public void addQueryDataListener(QueryDataListener l)
l
- The Listener to the add.public void removeQueryDataListener(QueryDataListener l)
l
- The Listener to remove.protected void fireCloseEvent()
public Transaction getTransaction()
Please note that if transacstion is not Transaction.AUTO_COMMIT you will need to call transaction.rollback() in the event of an SQLException.
public java.io.IOException cast(java.lang.String message, java.sql.SQLException sqlException)
Returns an IOException encapsulating the sqlException after correctly rolling back the current Transaction. Rollback only occurs if we are not using Transacstion.AUTO_COMMIT.
TODO: chris is this a good idea?
message
- DOCUMENT ME!sqlException
- DOCUMENT ME!
public java.sql.Connection getConnection()
public JDBCDataStore.FeatureTypeInfo getFeatureTypeInfo()
public boolean isInserting()
public void setInserting(boolean isInserting)
isInserting
- The isInserting to set.public void deleteCurrentRow() throws java.sql.SQLException
java.sql.SQLException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |