avignon.handlers.database
Class DLookupQuery

java.lang.Object
  extended byavignon.handlers.database.DLookupQuery
Direct Known Subclasses:
DCountQuery

public class DLookupQuery
extends java.lang.Object

Helper class for looking up a single value in a table or view.


Field Summary
protected  java.lang.String fieldName
           
protected  java.lang.String tableName
           
protected  java.lang.String whereCondition
           
 
Constructor Summary
DLookupQuery(java.lang.String tableName, java.lang.String fieldName)
          Constructs a query that assumes that there will be only one row in the given table/view or that the row is not significant to the result.
DLookupQuery(java.lang.String tableName, java.lang.String fieldName, java.lang.String whereCondition)
          Constructs a query that will lookup a particular value in a table/view based on the given where condition.
 
Method Summary
 java.lang.Object getObject(java.sql.Connection database)
          Executes the query against the given database.
protected  java.lang.String getWhereClause()
          Returns the empty string if no where condition has been specified, otherwise returns WHERE followed by the where condition.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tableName

protected java.lang.String tableName

fieldName

protected java.lang.String fieldName

whereCondition

protected java.lang.String whereCondition
Constructor Detail

DLookupQuery

public DLookupQuery(java.lang.String tableName,
                    java.lang.String fieldName)
Constructs a query that assumes that there will be only one row in the given table/view or that the row is not significant to the result.

Parameters:
tableName - Table or view in which the query will be run.
fieldName - Name of the field to return.

DLookupQuery

public DLookupQuery(java.lang.String tableName,
                    java.lang.String fieldName,
                    java.lang.String whereCondition)
Constructs a query that will lookup a particular value in a table/view based on the given where condition. If more than one records matches the where condition, the row used for the result is undefined. If no rows match the where condition, the result will be null.

Parameters:
tableName -
fieldName -
whereCondition -
Method Detail

toString

public java.lang.String toString()

getObject

public java.lang.Object getObject(java.sql.Connection database)
                           throws java.sql.SQLException
Executes the query against the given database.

Parameters:
database -
Returns:
Throws:
java.sql.SQLException

getWhereClause

protected java.lang.String getWhereClause()
Returns the empty string if no where condition has been specified, otherwise returns WHERE followed by the where condition.

Returns:

SourceForge.net Logo