net.sf.eodsql
Interface DataSet<T>

All Superinterfaces:
Collection<T>, Iterable<T>, List<T>

public interface DataSet<T>
extends List<T>

A DataSet allows access to objects mapped from a Select query. A DataSet implementation will include all of the required methods required by the List interface, optional methods may or may not be implemented, as the DataSet may be diconnected from the database or read-only.

A DataSet that was requested as connected will lazy-load objects from the database, and remains connected until it's close() method is called. A connected DataSet may use a cache of the objects, and so does not reflect changes in the database, for this a new request must be made. A connected DataSet may at any time disconnect from the database, and cache the entire ResultSet in memory. This is typically done when a method is called that requires the entire ResultSet (such as List.size()).

Exceptions resulting from calls to a DataSet object will be wrapped in a RuntimeException and be re-thrown. It is advised that DataSet access is wrapped in a try-catch block to avoid getting database errors where you don't want them. Errors are less likely to occur from disconnected DataSets.

Author:
jason

Method Summary
 void close()
          Requests that this DataSet release any database resources that it currently holds, such as ResultSet's, and Statement's.
 void disconnect()
          Requestes that this DataSet disconnect from the database cleanly, but still maintain it's functionality.
 boolean isConnected()
          Checks to see if this DataSet is currently connected to the database.
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Method Detail

close

void close()
Requests that this DataSet release any database resources that it currently holds, such as ResultSet's, and Statement's. Once this method has been called, attempting to call accessor methods on the DataSet may result in a RuntimeException (wrapping an SQLException).


isConnected

boolean isConnected()
Checks to see if this DataSet is currently connected to the database. If disconnect() or close() has been called, this will return false. It may also return false if the DataSet has disconnected for other reasons. If the DataSet was requested as disconnected, this will always return false.

Returns:
true if this DataSet is holding database resources

disconnect

void disconnect()
Requestes that this DataSet disconnect from the database cleanly, but still maintain it's functionality. If this method is called on a DataSet was requested as disconnected then this method will have no effect. Otherwise, if the DataSet is currently connected with the database it will copy the remaining results into it's internal cache, and then close() itself.