com.workingdogs.village
Class QueryDataSet

java.lang.Object
  |
  +--com.workingdogs.village.DataSet
        |
        +--com.workingdogs.village.QueryDataSet

public class QueryDataSet
extends DataSet

This class is used for doing SQL select statements on the database. It should not be used for doing modifications via update/delete/insert statements. If you would like to perform those functions, please use a TableDataSet.

Here is some example code for using a QueryDataSet.

QueryDataSet qds = new QueryDataSet ( connection, "SELECT * from my_table" );
qds.fetchRecords(10); // fetch the first 10 records
for ( int i = 0; i < qds.size(); i++ )
{
Record rec = qds.getRecord(i);
int value = rec.getValue("column").asInt();
System.out.println ( "The value is: " + value );
}
qds.close();
It is important to always remember to close() a QueryDataSet in order to free the allocated resources.

Version:
$Revision: 1.7 $
Author:
Jon S. Stevens jon@latchkey.com

Fields inherited from class com.workingdogs.village.DataSet
ALL_RECORDS, allRecordsRetrieved, columns, conn, keyDefValue, lastFetchSize, recordRetrievedCount, records, resultSet, schema, selectString, stmt, totalFetchCount
 
Constructor Summary
QueryDataSet()
          Private...does nothing.
QueryDataSet(java.sql.Connection conn, java.lang.String selectStmt)
          Creates a new QueryDataSet based on a connection and a select string
QueryDataSet(java.sql.ResultSet resultSet)
          Create a new QueryDataSet based on an existing resultSet
 
Method Summary
 java.lang.String getSelectString()
          get the Select String that was used to create this QueryDataSet
 
Methods inherited from class com.workingdogs.village.DataSet
addRecord, addRecord, allRecordsRetrieved, clearRecords, close, connection, containsRecord, fetchRecords, fetchRecords, fetchRecords, findRecord, getColumns, getRecord, keydef, lastFetchSize, maxColumnWidths, releaseRecords, removeRecord, reset, resultSet, schema, setAllRecordsRetrieved, size, tableName, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

QueryDataSet

public QueryDataSet()
             throws java.sql.SQLException,
                    DataSetException
Private...does nothing.
Throws:
java.sql.SQLException -  
DataSetException -  

QueryDataSet

public QueryDataSet(java.sql.Connection conn,
                    java.lang.String selectStmt)
             throws java.sql.SQLException,
                    DataSetException
Creates a new QueryDataSet based on a connection and a select string
Parameters:
conn -  
selectStmt -  
Throws:
java.sql.SQLException -  
DataSetException -  

QueryDataSet

public QueryDataSet(java.sql.ResultSet resultSet)
             throws java.sql.SQLException,
                    DataSetException
Create a new QueryDataSet based on an existing resultSet
Parameters:
resultSet -  
Throws:
java.sql.SQLException -  
DataSetException -  
Method Detail

getSelectString

public java.lang.String getSelectString()
get the Select String that was used to create this QueryDataSet
Overrides:
getSelectString in class DataSet
Returns:
a select string


Copyright © 1999-2002 Share.Whichever.com All Rights Reserved.