org.garret.consus
Class Query

java.lang.Object
  extended by org.garret.consus.Query

public class Query
extends java.lang.Object

Class used for construction of parameterized queries.


Constructor Summary
Query(java.sql.Connection con)
          Query constructor.
 
Method Summary
 Query add(java.lang.String cond)
          Append String to the statement.
 Query and(java.lang.String cond)
          Append a conjunct to the statement.
 ConsusResultSet executeQuery()
          Prepare and execute the query.
 int executeUpdate()
          Prepare and execute the update statement.
 Query param(boolean val)
          Bind the boolean parameter.
 Query param(double val)
          Bind the double parameter.
 Query param(float val)
          Bind the float parameter.
 Query param(int val)
          Bind the integer parameter.
 Query param(long val)
          Bind the long parameter.
 Query param(java.lang.Object val)
          Bind any object parameter.
 ConsusPreparedStatement prepare()
          Prepare the statement.
 void reset()
          Reset the query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Query

public Query(java.sql.Connection con)
Query constructor.

Parameters:
con - database connection
Method Detail

add

public Query add(java.lang.String cond)
Append String to the statement.

Parameters:
cond - appended string
Returns:
this

and

public Query and(java.lang.String cond)
Append a conjunct to the statement. If it is the first conjunct, it is prepended by " WHERE ", otherwise it is prepended by " AND ".

Parameters:
cond - appended conjunct
Returns:
this

executeQuery

public ConsusResultSet executeQuery()
                             throws java.sql.SQLException
Prepare and execute the query.

Returns:
ResultSet with results of the query execution
Throws:
java.sql.SQLException

executeUpdate

public int executeUpdate()
                  throws java.sql.SQLException
Prepare and execute the update statement.

Returns:
number of updated records
Throws:
java.sql.SQLException

param

public Query param(boolean val)
Bind the boolean parameter.

Parameters:
val - parameter value
Returns:
this

param

public Query param(double val)
Bind the double parameter.

Parameters:
val - parameter value
Returns:
this

param

public Query param(float val)
Bind the float parameter.

Parameters:
val - parameter value
Returns:
this

param

public Query param(int val)
Bind the integer parameter.

Parameters:
val - parameter value
Returns:
this

param

public Query param(long val)
Bind the long parameter.

Parameters:
val - parameter value
Returns:
this

param

public Query param(java.lang.Object val)
Bind any object parameter.

Parameters:
val - parameter value
Returns:
this

prepare

public ConsusPreparedStatement prepare()
                                throws java.sql.SQLException
Prepare the statement.

Returns:
prepared statement
Throws:
java.sql.SQLException

reset

public void reset()
Reset the query.