com.workingdogs.village
Class QueryDataSet

java.lang.Object
  extended by com.workingdogs.village.DataSet
      extended by 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: 564 $
Author:
Jon S. Stevens

Field Summary
 
Fields inherited from class com.workingdogs.village.DataSet
ALL_RECORDS, conn, records, resultSet, schema, selectString, stmt
 
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, getRecord, keydef, lastFetchSize, releaseRecords, removeRecord, reset, resultSet, schema, size, tableName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

Specified by:
getSelectString in class DataSet
Returns:
a select string


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.