|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.workingdogs.village.DataSet
com.workingdogs.village.TableDataSet
public class TableDataSet
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.
| Field Summary |
|---|
| Fields inherited from class com.workingdogs.village.DataSet |
|---|
ALL_RECORDS, conn, records, resultSet, schema, selectString, stmt |
| Constructor Summary | |
|---|---|
TableDataSet()
Default constructor. |
|
TableDataSet(java.sql.Connection conn,
Schema schema,
KeyDef keydef)
Creates a new TableDataSet object. |
|
TableDataSet(java.sql.Connection conn,
java.lang.String tableName)
Creates a new TableDataSet object. |
|
TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
KeyDef keydef)
Creates a new TableDataSet object. |
|
TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String columns)
Creates a new TableDataSet object. |
|
TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String columns,
KeyDef keydef)
Creates a new TableDataSet object. |
|
| Method Summary | |
|---|---|
java.lang.String |
attributes()
this is a string that contains the columns for the table that this TableDataSet represents. |
java.lang.String |
debugInfo()
Hell if I know what this does. |
DataSet |
fetchRecords()
Use the TDS fetchRecords instead of the DataSet.fetchRecords |
DataSet |
fetchRecords(int max)
Use the TDS fetchRecords instead of the DataSet.fetchRecords |
DataSet |
fetchRecords(int start,
int max)
Fetch start to max records. |
java.lang.String |
getSelectString()
Builds the select string that was used to populate this TableDataSet. |
KeyDef |
keydef()
Returns the KeyDef for the DataSet |
java.lang.String |
optimisticLockingCol()
Gets the table column used for optomistic locking. |
TableDataSet |
order(java.lang.String order)
Sets the value for the SQL portion of the ORDER statement |
TableDataSet |
other(java.lang.String other)
Sets the value for the SQL portion of the OTHER statement |
void |
refresh(java.sql.Connection conn)
This method refreshes all of the Records stored in this TableDataSet. |
boolean |
refreshOnSave()
Setting this causes each Record to refresh itself when a save() is performed on it. |
void |
removeDeletedRecords()
Removes any records that are marked as a zombie. |
java.sql.ResultSet |
resultSet()
Returns the ResultSet for the DataSet |
int |
save()
Saves all the records in the DataSet. |
int |
save(boolean intransaction)
Saves all the records in the DataSet with the intransaction boolean value. |
int |
save(java.sql.Connection conn,
boolean intransaction)
Saves all the records in the DataSet with the given connection and intransaction boolean value. |
int |
saveWithoutStatusUpdate(java.sql.Connection conn)
Not yet implemented |
Schema |
schema()
Returns the Schema for the DataSet |
void |
setOptimisticLockingColumn(java.lang.String olc)
Sets the table column used for optomistic locking. |
void |
setRefreshOnSave(boolean val)
Setting this causes each Record to refresh itself when a save() is performed on it. |
java.lang.String |
tableName()
The name of the table for which this TableDataSet was created. |
TableDataSet |
tableQualifier(java.lang.String tq)
This sets additional SQL for the table name. |
void |
updateStatus()
Not yet implemented |
TableDataSet |
where(java.lang.String where)
Sets the value for the SQL portion of the WHERE statement |
| Methods inherited from class com.workingdogs.village.DataSet |
|---|
addRecord, addRecord, allRecordsRetrieved, clearRecords, close, connection, containsRecord, getRecord, lastFetchSize, maxColumnWidths, releaseRecords, removeRecord, reset, size, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TableDataSet()
throws java.sql.SQLException,
DataSetException
java.sql.SQLException
DataSetException
public TableDataSet(java.sql.Connection conn,
java.lang.String tableName)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!tableName - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet(java.sql.Connection conn,
Schema schema,
KeyDef keydef)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!schema - TODO: DOCUMENT ME!keydef - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
KeyDef keydef)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!tableName - TODO: DOCUMENT ME!keydef - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String columns)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!tableName - TODO: DOCUMENT ME!columns - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet(java.sql.Connection conn,
java.lang.String tableName,
java.lang.String columns,
KeyDef keydef)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!tableName - TODO: DOCUMENT ME!columns - TODO: DOCUMENT ME!keydef - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!| Method Detail |
|---|
public DataSet fetchRecords()
throws java.sql.SQLException,
DataSetException
fetchRecords in class DataSetjava.sql.SQLException
DataSetException
public DataSet fetchRecords(int max)
throws java.sql.SQLException,
DataSetException
fetchRecords in class DataSetmax -
java.sql.SQLException
DataSetException
public DataSet fetchRecords(int start,
int max)
throws java.sql.SQLException,
DataSetException
fetchRecords in class DataSetstart - max -
java.sql.SQLException
DataSetExceptionpublic java.lang.String attributes()
public KeyDef keydef()
keydef in class DataSet
public java.sql.ResultSet resultSet()
throws java.sql.SQLException,
DataSetException
resultSet in class DataSetjava.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!public Schema schema()
schema in class DataSet
public int save()
throws java.sql.SQLException,
DataSetException
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public int save(boolean intransaction)
throws java.sql.SQLException,
DataSetException
intransaction - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public int save(java.sql.Connection conn,
boolean intransaction)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!intransaction - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public int saveWithoutStatusUpdate(java.sql.Connection conn)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!public java.lang.String debugInfo()
public void removeDeletedRecords()
throws DataSetException
DataSetException - TODO: DOCUMENT ME!public void setOptimisticLockingColumn(java.lang.String olc)
olc - TODO: DOCUMENT ME!public java.lang.String optimisticLockingCol()
public TableDataSet where(java.lang.String where)
throws DataSetException
where - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet order(java.lang.String order)
throws DataSetException
order - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public TableDataSet other(java.lang.String other)
throws DataSetException
other - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!
public void refresh(java.sql.Connection conn)
throws java.sql.SQLException,
DataSetException
conn - TODO: DOCUMENT ME!
java.sql.SQLException - TODO: DOCUMENT ME!
DataSetException - TODO: DOCUMENT ME!public void setRefreshOnSave(boolean val)
Default value is false.
val - TODO: DOCUMENT ME!public boolean refreshOnSave()
Default value is false.
public TableDataSet tableQualifier(java.lang.String tq)
FIXME: Is this right? I don't use Sybase.
tq - TODO: DOCUMENT ME!
public java.lang.String tableName()
throws DataSetException
tableName in class DataSetDataSetException - TODO: DOCUMENT ME!
public void updateStatus()
throws java.sql.SQLException,
DataSetException
java.sql.SQLException
DataSetException
public java.lang.String getSelectString()
throws DataSetException
getSelectString in class DataSetDataSetException - TODO: DOCUMENT ME!
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||