| java.lang.Object com.workingdogs.village.DataSet com.workingdogs.village.TableDataSet
TableDataSet | public class TableDataSet extends DataSet (Code) | | This class is used for doing select/insert/delete/update on the database. A TableDataSet cannot be used to join multiple tables
for an update, if you need join functionality on a select, you should use a QueryDataSet.
Here is an example usage for this code that gets the first 10 records where column "a" = 1:
KeyDef kd = new KeyDef().setAttrib("column");
TableDataSet tds = new TableDataSet(connection, "table_name", kd );
tds.where ("a=1" ); // WHERE a = 1
tds.fetchRecords(10); // fetch first 10 records where column a=1
for ( int i=0;i< tds.size(); i++ )
{
Record rec = tds.getRecord(i); // zero based
String columnA = rec.getValue("a");
if ( columnA.equals ("1") )
System.out.print ("We got a column!");
}
tds.close();
It is important to remember to always close() the TableDataSet when you are finished with it.
As you can see, using a TableDataSet makes doing selects from the database trivial. You do not need to write any SQL and it
makes it easy to cache a TableDataSet for future use within your application.
author: Jon S. Stevens version: $Revision: 568 $ |
Constructor Summary | |
public | TableDataSet() Default constructor. | public | TableDataSet(Connection conn, String tableName) Creates a new TableDataSet object. | public | TableDataSet(Connection conn, Schema schema, KeyDef keydef) Creates a new TableDataSet object. | public | TableDataSet(Connection conn, String tableName, KeyDef keydef) Creates a new TableDataSet object. | public | TableDataSet(Connection conn, String tableName, String columns) Creates a new TableDataSet object. | public | TableDataSet(Connection conn, String tableName, String columns, KeyDef keydef) Creates a new TableDataSet object. |
attributes | public String attributes()(Code) | | this is a string that contains the columns for the table that this TableDataSet represents.
columns separated by "," |
debugInfo | public String debugInfo()(Code) | | Hell if I know what this does.
TODO: DOCUMENT ME! |
getOrder | String getOrder()(Code) | | Gets the value of the SQL portion of ORDER.
string |
getOther | String getOther()(Code) | | Gets the value of the SQL portion of OTHER.
string |
getWhere | String getWhere()(Code) | | Gets the value of the SQL portion of WHERE.
string |
keydef | public KeyDef keydef()(Code) | | Returns the KeyDef for the DataSet
a keydef |
optimisticLockingCol | public String optimisticLockingCol()(Code) | | Gets the table column used for optomistic locking.
string |
refreshOnSave | public boolean refreshOnSave()(Code) | | Setting this causes each Record to refresh itself when a save() is performed on it.
Default value is false.
true if it is on; false otherwise |
save | public int save(boolean intransaction) throws SQLException, DataSetException(Code) | | Saves all the records in the DataSet with the intransaction boolean value.
Parameters: intransaction - TODO: DOCUMENT ME! total number of records updated/inserted/deleted throws: SQLException - TODO: DOCUMENT ME! throws: DataSetException - TODO: DOCUMENT ME! |
save | public int save(Connection conn, boolean intransaction) throws SQLException, DataSetException(Code) | | Saves all the records in the DataSet with the given connection and intransaction boolean value.
Parameters: conn - TODO: DOCUMENT ME! Parameters: intransaction - TODO: DOCUMENT ME! total number of records updated/inserted/deleted throws: SQLException - TODO: DOCUMENT ME! throws: DataSetException - TODO: DOCUMENT ME! |
schema | public Schema schema()(Code) | | Returns the Schema for the DataSet
a Schema |
setOptimisticLockingColumn | public void setOptimisticLockingColumn(String olc)(Code) | | Sets the table column used for optomistic locking.
Parameters: olc - TODO: DOCUMENT ME! |
setRefreshOnSave | public void setRefreshOnSave(boolean val)(Code) | | Setting this causes each Record to refresh itself when a save() is performed on it.
Default value is false.
Parameters: val - TODO: DOCUMENT ME! |
tableQualifier | public TableDataSet tableQualifier(String tq)(Code) | | This sets additional SQL for the table name. The string appears after the table name. Sybase users would set this to
"HOLDLOCK" to get repeatable reads.
FIXME: Is this right? I don't use Sybase.
Parameters: tq - TODO: DOCUMENT ME! an instance of self |
Methods inherited from com.workingdogs.village.DataSet | public Record addRecord() throws DataSetException, SQLException(Code)(Java Doc) public Record addRecord(DataSet ds) throws DataSetException, SQLException(Code)(Java Doc) public boolean allRecordsRetrieved()(Code)(Java Doc) public DataSet clearRecords()(Code)(Java Doc) public void close() throws SQLException, DataSetException(Code)(Java Doc) public Connection connection() throws SQLException(Code)(Java Doc) public boolean containsRecord(int pos)(Code)(Java Doc) public DataSet fetchRecords() throws SQLException, DataSetException(Code)(Java Doc) public DataSet fetchRecords(int max) throws SQLException, DataSetException(Code)(Java Doc) public DataSet fetchRecords(int start, int max) throws SQLException, DataSetException(Code)(Java Doc) Record findRecord(int pos) throws DataSetException(Code)(Java Doc) String getColumns()(Code)(Java Doc) public Record getRecord(int pos) throws DataSetException(Code)(Java Doc) abstract public String getSelectString() throws DataSetException(Code)(Java Doc) public KeyDef keydef()(Code)(Java Doc) public int lastFetchSize()(Code)(Java Doc) public int[] maxColumnWidths(boolean with_heading) throws DataSetException, SQLException(Code)(Java Doc) public DataSet releaseRecords()(Code)(Java Doc) public Record removeRecord(Record rec) throws DataSetException(Code)(Java Doc) public DataSet reset() throws DataSetException, SQLException(Code)(Java Doc) public ResultSet resultSet() throws SQLException, DataSetException(Code)(Java Doc) public Schema schema()(Code)(Java Doc) void setAllRecordsRetrieved(boolean set)(Code)(Java Doc) public int size()(Code)(Java Doc) public String tableName() throws DataSetException(Code)(Java Doc) public String toString()(Code)(Java Doc)
|
|
|