com.agimatec.sql
Class SQLStatement

java.lang.Object
  extended by com.agimatec.sql.SQLStatement

public class SQLStatement
extends Object

This class represents a SQLStatement with its parameters.


Constructor Summary
SQLStatement(String stmtString)
          Construct with the given sqlStatementString.
SQLStatement(String stmtString, List params)
          Construct with a given sqlStatementString an a parameter list
 
Method Summary
 void addParameter(Object value)
          Add the given value to the receiver's parameter list.
 PreparedStatement asPreparedStatement(Connection conn)
          Create a new JDBC PreparedStatement with the receiver's parameters.
 String getParameterizedStatement()
          return the statement including parameter values instead of ?
 List getParameters()
          Return the statement parameters
 SQLStatement getPreparedStatement()
          return a copy of the receiver or the receiver itself (when not changed) that is ready to be executed with asPreparedStatement(connection) where the SQL and parameters have been transformed so that execution result is the same as when the receiver would have been transformed by getParameterizedStatement().
 String getStatement()
          Return the sql statement string
 void logInfo(org.apache.commons.logging.Log log)
          Logging convenience - Log the receiver's sql (with ?
 void provideParameters(PreparedStatement stmt)
          Set the receiver's parameters into the given PreparedStatement.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SQLStatement

public SQLStatement(String stmtString)
Construct with the given sqlStatementString. You may provide the parameters with getParameters().add() afterwards.


SQLStatement

public SQLStatement(String stmtString,
                    List params)
Construct with a given sqlStatementString an a parameter list

Method Detail

getStatement

public String getStatement()
Return the sql statement string


getParameters

public List getParameters()
Return the statement parameters


addParameter

public void addParameter(Object value)
Add the given value to the receiver's parameter list.


asPreparedStatement

public PreparedStatement asPreparedStatement(Connection conn)
                                      throws SQLException
Create a new JDBC PreparedStatement with the receiver's parameters.

Throws:
SQLException

provideParameters

public void provideParameters(PreparedStatement stmt)
                       throws SQLException
Set the receiver's parameters into the given PreparedStatement. CAUTION: the given statement must match with the receiver!

Throws:
SQLException

logInfo

public void logInfo(org.apache.commons.logging.Log log)
Logging convenience - Log the receiver's sql (with ? instead of parameters) and parameters (separetely) onto the logdevice under info priority


getParameterizedStatement

public String getParameterizedStatement()
return the statement including parameter values instead of ?


toString

public String toString()
Overrides:
toString in class Object

getPreparedStatement

public SQLStatement getPreparedStatement()
return a copy of the receiver or the receiver itself (when not changed) that is ready to be executed with asPreparedStatement(connection) where the SQL and parameters have been transformed so that execution result is the same as when the receiver would have been transformed by getParameterizedStatement().

into adequate strings and modifies the statement so that correct behavior is guaranteed. Note: Parameters of Collection types are generated into the statement as separate parameters.



Copyright © 2008-2012. All Rights Reserved.